Trying to merge 6 columns of first row looping

Opany

New Member
Joined
Jun 1, 2015
Messages
2
Hi all,

I am trying to create a macro which will merge the cells (A1:F1), then (G1:L1) and every 6 cells in the row from there on.

The code I am currently using is as follows:

Code:
Sub ColumnMerge()    
Dim Range As Range
    For x = 1 To 1000 Step 6
        Range = (Cells(1, x), Cells(1, x + 5)).Merge
    Next x
End Sub

However, I am getting a syntax error for the range reference. I'm sure it's a fairly basic mistake but I'm new to VBA so please bear with me. I realize data could be lost with the merge function but since its only going to be used on blank cells, I'm happy enough to use merge.

If someone could point out the correct way to reference the range I would appreciate it.

Thanks,

Opany
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Code:
Sub ColumnMerge()
    For x = 1 To 1000 Step 6
        Range(Cells(1, x), Cells(1, x + 5)).Merge
    Next x
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,606
Messages
6,056,281
Members
444,854
Latest member
goethe168

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