i need macro to open files and save files and open next file

November 1, 2012 at 02:14:16
Specs: Windows XP
i made macro that does needed things to my file, then it needs to save the file and open the next file and run the macro again, and once again save and open, and i get few times in a week dozens of these files

So what kind of script would save the file and open next file and autorun macro

See More: i need macro to open files and save files and open next file

Report •

November 1, 2012 at 02:33:58
here is the macro code that needs to be done to the files:

Dim BtmRow As Long
Bottom = Sheets(1).Range("A65536").End(xlUp).Row

ActiveCell.FormulaR1C1 = "1"
ActiveCell.FormulaR1C1 = "2"
ActiveCell.FormulaR1C1 = "3"
Selection.AutoFill Destination:=Range("D1:D" & Bottom), Type:=xlFillSeries


Report •

November 2, 2012 at 00:31:52
Nevermind... i found other way to make it work

Report •

November 2, 2012 at 08:53:15
Just FYI...

Rarely do you have to Select cells in VBA to perform an action on them. Selecting each cell is very inefficient. Your code can be reduced to this:

  Dim BtmRow As Long
    Range("D1").FormulaR1C1 = "1"
    Range("D2").FormulaR1C1 = "2"
    Range("D3").FormulaR1C1 = "3"
      Range("D1:D3").AutoFill Destination:=Range("D1:D" & Bottom), _

or even:

 Bottom = Sheets(1).Range("A65536").End(xlUp).Row
  For nxtRw = 1 To Bottom
    Range("D" & nxtRw) = nxtRw

I should also point out that while Sheets(1).Range("A65536").End(xlUp).Row works fine in Excel versions earlier than 2007, it might not work in 2007 and beyond.

In 2007 and later, there are more than 65536 rows available in a spreadsheet.

This code, which will work in any version that supports VBA, is the new standard:

Bottom = Sheets(1).Range("A" & Rows.Count).End(xlUp).Row

Since Rows.Count will return the number of Rows in any spreadsheet, it is backward compatible to all versions of Excel that support VBA.

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

Related Solutions

Ask Question