Excel Macro [Solved/Closed]

Report
-
 MacroNewbie -
Hello,

I wonder if anyone can help me with a small (I think) problem, please?

I'm trying to write a macro to manipulate a spreadsheet sent to me by an external source. It contains a list of transactions with a summary below.
In order to format the summary in the way I want, I need to unmerge the cells it appears in.

I'm trying to put in something like:

x = InputBox("How many transactions?")
Rows("(x+12):(x+12)").Select
Selection.UnMerge

but it's not working.

Many thanks for anyone's suggestions on how I could do this instead,
A Macro Newbie.

1 reply

Posts
2744
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
May 10, 2021
461
Hello Macro Newbie,

Your problem is this line:
Rows("(x+12):(x+12)").Select 
Change it into this:
Rows(x + 12).Select
Best regards,
Trowa
Thanks so much for this.
It's now stalling at a similar line:
Range("a(x+12):q(x+12)").Select
Selection.Merge
where I am trying to merge columns A to Q on my row (x+12). Is there another way to describe this range?
Many thanks in advance for anyone's help on this again.
Regards.
Posts
2744
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
May 10, 2021
461
To correct your line:
Range("A" & (x + 12) & ":Q" & (x + 12)).Select

I personally would use:
Range(Cells(x + 12, "A"), Cells(x + 12, "Q")).Select

Best regards,
Trowa
Thank You. I've got it going now :o)

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!