VBA and Macros
VBA and Macros
VBA and Macros
Do Until x = 6
MsgBox x
x=x+1
Loop
Range("B3").Activate Do until i=13
i=1
Do Until i = 13
ActiveCell.Value = i
ActiveCell.Offset(1, 0).Activate
i=i+1
Range("K3").Activate Do until and IF
For i = 1 To x
ActiveCell.Value = Sheets(i).Name
ActiveCell.Offset(1, 0).Activate
Next
Cells.Select Selects all the cells in the sheet
Next
Worksheets("Sheet1").Activate Merge contents of all sheets to another sheet in the
Range("A2").Activate same workbook
(Doesn't copy the headings and so the first heading
sh = Sheets.Count - 1 has to manually included in the merged sheet before-
For i = 1 To sh hand)
Sheets(i).Activate
x = Range("A2").CurrentRegion.Rows.Count
y = Range("A2").CurrentRegion.Columns.Count
Next
Path="D:\New files 2012\VBA Training\merge\" Copy and paste all the sheets from all files in a
Path = "C:\Users\Bernard Eugine\Desktop\VBA Macro - Excel Prodigy\Report\" directory after the last sheet of the current workbook
Do Until fn = ""
Workbooks.Open Path & fn
Sheets.Copy after:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
Workbooks(fn).Close
fn = Dir()
Loop
Exit Sub
msg1:
ActiveCell.Value = 0
Resume Next
Function servicetax(amt As Double, tax As Double) Creating a function to receive tax rate and amount to
servicetax = amt * tax calculate service tax
End Function
Sheet2.Activate Enter a log of the names of the users opening the file
x = InputBox("Enter your name") in Sheet 2
ActiveCell.Value = x Sheet 2 is Very Hidden
ActiveCell.Offset(0, 1).Value = Now Workbook is auto-saved after antering the name
ActiveCell.Offset(1, 0).Activate
Sheet5.Visible = x1sheetveryhidden
ActiveWorkbook.Save