rakeshbrraag
New member
- Joined
- Nov 23, 2012
- Messages
- 10
- Reaction score
- 0
- Points
- 0
- Excel Version(s)
- 2013
Hello everyone,
I have a code which copies specific columns certain number of times, Here is the code:
Can anyone help me with the second line(marked in red). I want the same code working without With as i am getting some errors when looping this code
I have a code which copies specific columns certain number of times, Here is the code:
Code:
Sub Copy_Columns()
Dim lastr As Double
Dim cols As Double
cols = Sheets("Sheet1").Range("V4").Value * 3 ' Determine how many columns to copy across
[COLOR=#ff0000] With Sheets("Sheet2")[/COLOR]
lastr = .UsedRange.Rows.Count ' Last used row in worksheet
.Range("D1:F" & lastr).Select
Selection.AutoFill Destination:=Range(Cells(1, 4), Cells(lastr, cols + 3)), Type:=xlFillDefault
End With
End Sub
Can anyone help me with the second line(marked in red). I want the same code working without With as i am getting some errors when looping this code
Last edited by a moderator: