我试图编写一个循环来搜索列中的每个填充单元格" J"在sheet2中,并隐藏sheet1中的相应行。例如,如果单元格J1是" 30"则会隐藏sheet1中的第30行。这就是我到目前为止所拥有的:
Sub test()
Dim myrng As Range
Dim ws As Worksheet
Dim i As Integer
Dim lrow As Long, value As Long
Dim cell As Variant
Set ws = Sheet2
lrow = ws.Range("J" & Rows.Count).End(xlUp).Row
For i = 1 To lrow
value = ws.Cells(i, 10).value
cell = "A" & value
Sheet1.[cell].EntireRow.Hidden = True
Next i
End Sub
一切正常,除了线" Sheet1。[value] .entirerow.hidden = true"。我可能使用了错误的语法。任何想法/帮助将不胜感激!
谢谢, 金