我需要复制" sheet1"到另一张纸" sheet2"在一个包含VBA中特定日期的单元格下,但每次我想要运行procdurem时,如果某人有一个aswer给我这将是非常有用的
我的程序:
Dim n As Date:
Dim c As Range:
Dim cellule As Range:
n = ws.Range("E3").Value ''this is the critera i need
ws.Range("B3:B6").Copy '' this is the selection i need
For Each c In ws2.Range("B1:D1") ''' the criteria is in this selection
If c.Value = n Then
cellule = c.Offset(3, 0).Address ''' this does not work
ws2.Range(cellule).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
Exit For
End If
Next
或者,如果你想到其他事情,请告诉我
答案 0 :(得分:1)
您已将cellule
声明为范围,但地址是范围的属性和字符串。你可以这样做。
Dim n As Date
Dim c As Range
Dim cellule As Range
n = ws.Range("E3").Value ''this is the critera i need
For Each c In ws2.Range("B1:D1") ''' the criteria is in this selection
If c.Value = n Then
ws.Range("B3:B6").Copy
c.Offset(3, 0).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
Exit For
End If
Next c