Well, I've gotten really far in the last six weeks with VBA in both Access and Excel without asking a question but I can't work this one out (and I know it's going to be simple).
I'm running the code below (cobbled together from various sources on the web) to extract the last row number from each of many spreadsheets and put them (the row numbers) in column A of a tally spreadsheet. I'm getting "Run-time error 1004, App Defined or Object Defined Error" on the "Offset" line.
Thanks in advance for any help you can offer. (And I apologize for the awkward formatting of the code but I can't really manipulate it in this forum editor.)
Mark
Sub ExtractSORData()
Dim myFile As String, myCurrFile As String, LastRow As Integer
myCurrFile = ThisWorkbook.Name
myFile = Dir("G:\CCM\SORS\2010 Spring Summer\2010 Spring FT\*.xls")
Do Until myFile = ""
Workbooks.Open "G:\CCM\SORS\2010 Spring Summer\2010 Spring FT\" & myFile
Worksheets("scan data").Activate
Range("A75").End(xlUp).Select
LastRow = ActiveCell.Row
Workbooks(myCurrFile).Worksheets("Sheet1").Range("A1").End(xlDown).Offset(1, 0) = LastRow
Workbooks(myFile).Close savechanges:=False
myFile = Dir
Loop
End Sub
I'm running the code below (cobbled together from various sources on the web) to extract the last row number from each of many spreadsheets and put them (the row numbers) in column A of a tally spreadsheet. I'm getting "Run-time error 1004, App Defined or Object Defined Error" on the "Offset" line.
Thanks in advance for any help you can offer. (And I apologize for the awkward formatting of the code but I can't really manipulate it in this forum editor.)
Mark
Sub ExtractSORData()
Dim myFile As String, myCurrFile As String, LastRow As Integer
myCurrFile = ThisWorkbook.Name
myFile = Dir("G:\CCM\SORS\2010 Spring Summer\2010 Spring FT\*.xls")
Do Until myFile = ""
Workbooks.Open "G:\CCM\SORS\2010 Spring Summer\2010 Spring FT\" & myFile
Worksheets("scan data").Activate
Range("A75").End(xlUp).Select
LastRow = ActiveCell.Row
Workbooks(myCurrFile).Worksheets("Sheet1").Range("A1").End(xlDown).Offset(1, 0) = LastRow
Workbooks(myFile).Close savechanges:=False
myFile = Dir
Loop
End Sub