I am currently working a script that if the Col E is greater than 1, then VBA is to perform copy col A & Col C data into another spreadsheet.
Follow the Col E data. If col E is 1, means copy 1 time, if Col E is 10, then need to perform copy & paste 10 times.
With below VBA, I not sure why is there an error point while it prompt error type mismatch for <For n = 1 To k>..
Is there any suggestion?
Dim myrange As Range
Dim k As Range
Dim lastrow As Long
Dim n As Integer
Sheets("Sheet1").Activate
lastrow = Range("A" & Rows.Count).End(xlUp).Row
Set myrange = Range("E3:E" & lastrow)
For Each k In myrange
If k.Value > 1 Then
For n = 1 To k
k.Offset(0, -4).Copy
Sheets("Sheet2").Range("A3:A" & lastrow).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Next n
End If
Next
Follow the Col E data. If col E is 1, means copy 1 time, if Col E is 10, then need to perform copy & paste 10 times.
With below VBA, I not sure why is there an error point while it prompt error type mismatch for <For n = 1 To k>..
Is there any suggestion?
Dim myrange As Range
Dim k As Range
Dim lastrow As Long
Dim n As Integer
Sheets("Sheet1").Activate
lastrow = Range("A" & Rows.Count).End(xlUp).Row
Set myrange = Range("E3:E" & lastrow)
For Each k In myrange
If k.Value > 1 Then
For n = 1 To k
k.Offset(0, -4).Copy
Sheets("Sheet2").Range("A3:A" & lastrow).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Next n
End If
Next