[go: up one dir, main page]

0% found this document useful (0 votes)
26 views20 pages

VBA With Excel

The document provides a series of VBA (Visual Basic for Applications) code snippets for various tasks in Excel, including renaming sheets, copying sheets, changing tab colors, moving sheets, hiding/unhiding sheets, and creating new workbooks. Each task is accompanied by a brief description and the corresponding VBA code. The document serves as a guide for users looking to automate Excel operations using VBA.

Uploaded by

tapeshmandal2461
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views20 pages

VBA With Excel

The document provides a series of VBA (Visual Basic for Applications) code snippets for various tasks in Excel, including renaming sheets, copying sheets, changing tab colors, moving sheets, hiding/unhiding sheets, and creating new workbooks. Each task is accompanied by a brief description and the corresponding VBA code. The document serves as a guide for users looking to automate Excel operations using VBA.

Uploaded by

tapeshmandal2461
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Click to edit Master title style

work on sheets in
vba

1 1
Click
Renameto edit Master
sheet title style
in vba

• Sub renamesheet()
• Sheets(2).Name = "ProFession"
• Sheets("Sheet3").Name = "NewDataSheet"
• End Sub

2 2
Click to editinMaster
copy sheet vba title style

• Sub copysheet()
• Sheets("ProFession").Copy after:=Sheets("NewDataSheet")
• Sheets("ProFession").Copy before:=Sheets("Sheet1")
• End Sub

3 3
Click to edit
copy data of Master titleinto
one sheet style
another with name
"data"
• Sub task1_sheet()
• Sheets("ProFession").Copy after:=Sheets("NewDataSheet")
• Sheets("ProFession (2)").Name = "Data"
• End Sub

4 4
Click
how totochange
edit Master
sheettitle
tabstyle
color:

• Sub sheet_tab_color()
• Sheets(3).Tab.Color = vbGreen
• Sheets(3).Tab.Color = vbRed
• Sheets(3).Tab.Color = vbWhite
• End Sub

5 5
Click
moveto edit in
sheet Master
vba title style

• Sub move_sheet()
• Sheets("ProFession").Move after:=Sheets("NewDataSheet")
• Sheets("ProFession").Move before:=Sheets(1)
• End Sub

6 6
Click to edit
hide and Master
unhide thetitle
sheetstyle

• Sub hidesheet()
• Sheets("Sheet1").Visible = False
• Sheets("Sheet1").Visible = True
• End Sub

7 7
Click
How toto add
editsheet
Masterintitle
vba style

• Sub add_sheet()
• Sheets.Add after:=Sheets("NewDataSheet")
• Sheets.Add before:=Sheets("ProFession")
• End Sub

8 8
Click
How toto get
editsheet
Master title style
name

• Sub getsheet_name()
• MsgBox (Sheets(2).Name)
• MsgBox (Sheets(4).Name)
• End Sub

9 9
Click
how totoactivate
edit Master
any title
sheet style
in workbook

• Sub activateSheet()
• Sheets("Sheet3").Activate
• Sheets("Sheet2").Select
• End Sub

10
10
Click
how totocopy
edit Master title
data from style
one sheet to another

• Sub copydata()
• Sheets("Sheet1").Range("a2:a7").Copy
• Sheets("Sheet4").Select
• Range("B4").Select
• ActiveSheet.Paste
• End Sub

11
11
Click to edit Master title style

Work On WorkBook

12
12
Click
how totocreate
edit Master
a newtitle style
workbook

• Sub createworkbook()
• Workbooks.Add.SaveAs Filename:="F:\dinesh.xlsx"
• End Sub

13
13
Click
how totoget
editname
Master title style
of workbook

• Sub get_workbook_name()
• Dim name As Variant
• 'name = ThisWorkbook.name
• 'name = ActiveWorkbook.name
• MsgBox name
• End Sub

14
14
Click
how totoactivate
edit Master
any title style
workbook

• Sub activate_workbook()
• Workbooks("asd.xlsm").Activate
• Dim name As Variant
• name = ActiveWorkbook.name
• MsgBox name
• End Sub

15
15
Click
how to edit
writeMaster title
any data onstyle
any workbook sheet

• Sub activate_workbook()
• Workbooks("asd.xlsm").Activate
• Sheets("Sheet2").Range("b3:b5").Value = "VBA"
• End Sub

16
16
Click
How toto open
edit Master title style
workbook

• Sub save_close_workbook()
• Workbooks.Open Filename:="F:\VD.xlsx“
• Workbooks("VD.xlsx").Sheets(1).Range("a1") = 23000
• End Sub

17
17
Click
How toto save
edit Master title
and close style
closeworkbook

• Sub save_close_workbook()
• Workbooks.Add.SaveAs Filename:="F:\VD.xlsx"
• Workbooks("VD.xlsx").Close
• End Sub

18
18
Click
how totocreate
edit Master
foldertitle style

• Sub save_close_workbook()
• MkDir ("F:\v1")
• MkDir ("F:\v2")
• MkDir ("F:\v1\v3")
• MkDir ("F:\v1\v2")
• End Sub

19
19
Click to edit Master title style


Task:
copy the data from existing
workbook then paste in new excel
workbook(mybook.xlsx) then save
and close.

20
20

You might also like