I am writing a Macro to find the first blank row at the of a list. It worked great when I tested it on small file. Once I tried to implement it on a large file with 94890 rows, I am not getting the correct value. I have tried many ways of debugging to find out what the problem is but I cant seem to figure it out. I will copy my code and maybe someone can help with this issue. I keep getting the row value to be 29, it will not count any higher than that. In the code I commented out the screen updating and added a message box to allow myself to see the value. Sorry if the code is not embedded but I am new to this.
Sub PutDataInClosedWorkbook(ByVal yr As Integer, mk As String, modl As String, lookup As String)
Dim wb As Workbook, NextRow As Double
'Application.ScreenUpdating = False ' turn off the screen updating
Set wb = Workbooks.Open("C:\Lookup\VIN2.xlsx")
' open the source workbook
With ThisWorkbook.Worksheets("VIN")
' write data to the source workbook
NextRow = .Range("A1").End(xlDown).Row + 1
MsgBox NextRow
.Range("A" & NextRow).Value = lookup
.Range("B" & NextRow).Value = yr
.Range("C" & NextRow).Value = mk
.Range("D" & NextRow).Value = modl
End With
wb.Save
wb.Close ' close the source workbook and saves any changes
Set wb = Nothing ' free memory
'Application.ScreenUpdating = True ' turn on the screen updating
End Sub
Thanks for the help
Bookmarks