我找到了一种根据标准在电子表格中获取新信息的方法。我的问题是一行给了我一个应用程序定义或对象定义的错误。我不知道为什么会这样。这些代码的作用的解释在评论中。任何帮助表示赞赏!提前谢谢。
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
答案 0 :(得分:1)
那些引用看起来很可疑我......
您有以下内容:
Range(“A” & Rows.Count)
^ ^
---¦ ¦---
¦ ¦
Chr(147) Chr(148)
实际上这些Chr(147)
和Chr(148)
- 您需要的是"
Chr(34)
答案 1 :(得分:0)
A周围的引号不是正确的字符。将它们替换为Enter键旁边的双引号。
此外,在' A'之后立即包含Rows.Count的ActiveSheet引用。