KAMRAN AJ
05-04-2023, 03:33 PM
Below is a code it is on the file name if I change the file name it will not work, please make it for an active workbook. Now my workbook name is Windows("io_2022-09-16.xlsx").Activate
Sub test4()
' test4 Macro pass
Workbooks.Add
Range("A1").Select
ActiveCell.FormulaR1C1 = "MB_ID"
Range("B1").Select
ActiveCell.FormulaR1C1 = "Website"
Range("C1").Select
ActiveCell.FormulaR1C1 = "Business Name"
Range("D1").Select
ActiveCell.FormulaR1C1 = "Last Name"
Range("E1").Select
ActiveCell.FormulaR1C1 = "Address"
Range("F1").Select
ActiveCell.FormulaR1C1 = "Country"
Range("G1").Select
ActiveCell.FormulaR1C1 = "City"
Range("H1").Select
ActiveCell.FormulaR1C1 = "State"
Range("I1").Select
ActiveCell.FormulaR1C1 = "Postal Code"
Range("J1").Select
ActiveCell.FormulaR1C1 = "Phone"
Range("K1").Select
ActiveCell.FormulaR1C1 = "Email"
Range("L1").Select
ActiveCell.FormulaR1C1 = "Business Type"
Range("M1").Select
ActiveCell.FormulaR1C1 = "Industry"
Range("N1").Select
ActiveCell.FormulaR1C1 = "Lead Import Source"
Range("N2").Select
ActiveCell.FormulaR1C1 = "Data Import MB"
Range("O1").Select
ActiveCell.FormulaR1C1 = "Contact Type"
Range("O2").Select
ActiveCell.FormulaR1C1 = "New Lead"
Range("P1").Select
ActiveCell.FormulaR1C1 = "Migrating From"
Range("P2").Select
ActiveCell.FormulaR1C1 = "MINDBODY"
Range("Q1").Select
ActiveCell.FormulaR1C1 = "Import ID"
Range("Q2").Select
ActiveCell.FormulaR1C1 = "KA 2023_May 02, May 04"
Windows("PERSONAL.XLSB").Activate
Windows("io_2022-09-16.xlsx").Activate
End Sub
Details
I make a code but it is on the file name, if i change the workbook name it will not work please make it for an active workbook
Sub test4()
' test4 Macro pass
Workbooks.Add
Range("A1").Select
ActiveCell.FormulaR1C1 = "MB_ID"
Range("B1").Select
ActiveCell.FormulaR1C1 = "Website"
Range("C1").Select
ActiveCell.FormulaR1C1 = "Business Name"
Range("D1").Select
ActiveCell.FormulaR1C1 = "Last Name"
Range("E1").Select
ActiveCell.FormulaR1C1 = "Address"
Range("F1").Select
ActiveCell.FormulaR1C1 = "Country"
Range("G1").Select
ActiveCell.FormulaR1C1 = "City"
Range("H1").Select
ActiveCell.FormulaR1C1 = "State"
Range("I1").Select
ActiveCell.FormulaR1C1 = "Postal Code"
Range("J1").Select
ActiveCell.FormulaR1C1 = "Phone"
Range("K1").Select
ActiveCell.FormulaR1C1 = "Email"
Range("L1").Select
ActiveCell.FormulaR1C1 = "Business Type"
Range("M1").Select
ActiveCell.FormulaR1C1 = "Industry"
Range("N1").Select
ActiveCell.FormulaR1C1 = "Lead Import Source"
Range("N2").Select
ActiveCell.FormulaR1C1 = "Data Import MB"
Range("O1").Select
ActiveCell.FormulaR1C1 = "Contact Type"
Range("O2").Select
ActiveCell.FormulaR1C1 = "New Lead"
Range("P1").Select
ActiveCell.FormulaR1C1 = "Migrating From"
Range("P2").Select
ActiveCell.FormulaR1C1 = "MINDBODY"
Range("Q1").Select
ActiveCell.FormulaR1C1 = "Import ID"
Range("Q2").Select
ActiveCell.FormulaR1C1 = "KA 2023_May 02, May 04"
Windows("PERSONAL.XLSB").Activate
Windows("io_2022-09-16.xlsx").Activate
End Sub
Details
I make a code but it is on the file name, if i change the workbook name it will not work please make it for an active workbook