How do I create a loop to merge contents of rows 1-4 across column

G

Guest

Unfortunately, my Excel VBA Programming skills are weak. I need help in
creating a loop to merge rows by column. I have a spreadsheet that loads a
text file for any numbers of rows. I need to reserve rows 1-4 for column
heading information. the column spread is "a" - "FG". Can someone give me a
shell to work with?
Thank you
 
P

Peter T

Sub MergeHeaders()
Dim rng As Range, rCol As Range

Set rng = Range("A1:FG4")
rng.MergeCells = False
For Each rCol In rng.Columns
rCol.Merge
Next

End Sub

if you don't want any warnings about loosing data in cells about to be
merged start with
Application.displayalerts = false and reset same to true when done.

Instead of merging why not select the row-1, adjust height to that of 4 rows
and format wrap text.

Regards,
Peter T
 
G

Guest

Peter;
Thank you I'll give a try as well as your alternative suggestion. Time
well spent.
Helmut
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top