Copy Column range values in Excel VBA

Monty9

New Member
Joined
Feb 26, 2016
Messages
26
Office Version
  1. 365
Platform
  1. Windows
Hello Guys,

I am trying to copy excel column values from the Left column to the immediate next right column. like in the screenshot. May I request your support for a code to copy Column A1:A6 to B1:B6 and then jump to column D1:D6 to be copied to E1:E6 and jump further to G1:G2 and so on till last column. The table structure is fixed with 3 columns as shown in screenshot and won't change.

Thanks
 

Attachments

  • MultiColumn.JPG
    MultiColumn.JPG
    36.4 KB · Views: 7

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Try this:
VBA Code:
Sub MyCopy()

    Dim lc As Long
    Dim c As Long
 
    Application.ScreenUpdating = False
   
'   Find last column in row 1 with data
    lc = Cells(1, Columns.Count).End(xlToLeft).Column
   
'   Copy blocks of data
    c = 1
    Do
'       Copy block of data, from rows 1-6
        Range(Cells(1, c), Cells(6, c)).Copy Cells(1, c + 1)
'       Increment column counter by 3
        c = c + 3
'       If column counter greater than last column, exit
        If c > lc Then Exit Do
    Loop

    Application.ScreenUpdating = True
   
End Sub
 
Upvote 0
Solution
Try this:
VBA Code:
Sub MyCopy()

    Dim lc As Long
    Dim c As Long
 
    Application.ScreenUpdating = False
  
'   Find last column in row 1 with data
    lc = Cells(1, Columns.Count).End(xlToLeft).Column
  
'   Copy blocks of data
    c = 1
    Do
'       Copy block of data, from rows 1-6
        Range(Cells(1, c), Cells(6, c)).Copy Cells(1, c + 1)
'       Increment column counter by 3
        c = c + 3
'       If column counter greater than last column, exit
        If c > lc Then Exit Do
    Loop

    Application.ScreenUpdating = True
  
End Sub
Thank you Joe. Works exactly as required.
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,217
Members
449,074
Latest member
cancansova

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