Range("D2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("工作表1").Select
Range("A2").Select
ActiveSheet.Paste
Range("A2").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=TEXT(IT_VPN_Login_20211008__2[@使用者],""000000"")"
Selection.AutoFill Destination:=Range("A2:A250")
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
各位大大..程式我真的不行..請問..
這行的 Selection.AutoFill Destination:=Range("A2:A250")
A250 我要如何抓該行的最後一個數..因為這行數字不是固定的..
Sub test()
arr = Worksheets("工作表3").Range("d2:d" & Worksheets("工作表3").[d1048576].End(xlUp).Row)
Worksheets("工作表1").[a2].Resize(UBound(arr), 1) = arr
End Sub
1.插入三列以取得 250 這個數字, 設為 nRow
2.在 AutoFill 那列使用 nRow 這個變數
Range("D2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("工作表1").Select
Range("A2").Select
ActiveSheet.Paste
Range("A2").Select
Selection.End(xlDown).Select
nRow = ActiveCell.Row
Range("A2").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=TEXT(IT_VPN_Login_20211008__2[@使用者],""000000"")"
Selection.AutoFill Destination:=Range("A2:A" & nRow)
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select