Reputation: 51
I found a way to grab new information in a spreadsheet based on criteria. My problem is with one line that gives me an application defined or object defined error. I do not know why this is happening. The explanation of what this code does is in the comments. Any help is appreciated! Thanks in advance.
Public Sub Check_Price_Click()
'This code block runs through the data and if the first column is equal to the current date and the third column is equal to a Brand
'then copy new data to different workbook and repeat
Dim LastRow As Integer, i As Integer, erow As Integer
'This line of code is not working
LastRow = ActiveSheet.Range(“A” & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Cells(i, 1) = Date And Cells(i, 3) = Cells(i, 3).Value Then
Range(Cells(i, 1), Cells(i, 157)).Select
Selection.Copy
Workbooks.Open Filename:="C:\Users\Sales1\Dropbox\Davids Files\Macro Work\Daily Progress.xlsx"
Worksheets(“Sheet1”).Select
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Cells(erow, 1).Select
ActiveSheet.Paste
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.CutCopyMode = False
End If
Next i
End Sub
Upvotes: 1
Views: 86
Reputation: 17627
Those quotes look suspiciously deviant to me...
You have the following:
Range(“A” & Rows.Count)
^ ^
---¦ ¦---
¦ ¦
Chr(147) Chr(148)
Those are in fact Chr(147)
and Chr(148)
- what you need is "
which is Chr(34)
Upvotes: 1
Reputation: 14754
The quotes around the A are not the correct character. Replace them with the double-quote next to the Enter key.
Also, include the ActiveSheet reference for the Rows.Count immediately after the 'A'.
Upvotes: 0