Incement column in VBA

wilest

New Member
Joined
Apr 29, 2011
Messages
12
Hi
I desperately need help. I want my macro to:
select A1:C68 and cut it and paste it on another place and the
select D1:F68 and cut it and paste it on another place etc etc
Please help!

Code:
    Dim i As Integer
    var1col = 1
    var2col = 3
    var3 = 1
    For i = 1 To 100
    Windows("Book2").Activate
    Range(var1col & "1" & ":" & "68" & var2col).Select
    Selection.Cut
    Windows("results.xlsx").Activate
    Range("E" & var3).Select
    ActiveSheet.Paste
    var1col = var1col + 3
    var2col = var2col + 3
    var3 = var3 + 68
    Next i

 
You are a genius, thank you so much, I did the following changes and it worked like a charm:

Code:
Sub CopyMe()
Dim wbSrc As Workbook
Dim wbDst As Workbook
Dim wsSrc As Worksheet
Dim wsDst As Worksheet
Dim rngSrc As Range
Dim rngDst As Range

    Set wbSrc = ActiveWorkbook
    
    Set wsSrc = wbSrc.Worksheets("Sheet1")
    
    
    Set rngSrc = wsSrc.Range("A1:C68")
    
    Set wbDst = Workbooks("results.xlsx")
    
    Set wsDst = wbDst.Worksheets("Sheet1")
    Set rngDst = wsDst.Range("E1")
        
    Dim i As Integer
    For i = 1 To 1000
    
   
        rngSrc.Copy rngDst
        
        rngSrc.Clear
        
        Set rngSrc = rngSrc.Offset(, 3)
        
        Set rngDst = rngDst.Offset(68)
    Next i

    
End Sub

Thank you for the great forum!
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Glad you got it working.

Just out of curiosity did the original While...Wend loop not work?
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,280
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top