Reputation: 21
I have This code :
Dim w As Long
Dim wb As Workbook
Dim sht As Worksheet
Set wb = ActiveWorkbook
Set sht = wb.ActiveSheet
Dim lRow As Long
Dim lCol As Long
lRow = Cells(Rows.Count, 1).End(xlUp).Row
lCol = Cells(4, Columns.Count).End(xlToLeft).Column
For w = 1 To lCol
Range(.Cells(1, w), .Cells(2, w), .Cells(3, w)).Merge
Next w
I want to make the cells Merged and Centered like this :
But I cannot find the right way to make it. I want to Merge the first 3 cells in every column Example : A1:A3, but there are too many columns so i want to loop through them . Thank you!
Upvotes: 0
Views: 607
Reputation: 21
I figured it out! This is the answer
For w = 1 To lCol
With sht
Range(Cells(1, w), Cells(3, w)).Merge
End With
Next w
Upvotes: 1