PDA

View Full Version : [SOLVED:] VBA - Formatting Height of two Merged rows



JB99
08-13-2021, 04:12 AM
Hi folks,

first post, fairly new to VBA.

I want to automate the formatting of daily reports. So far everything works fine, but i can't find away for the following issue:

I address a cell which is merged across two rows (eg. A60:A61), in which i want to increase the height of the lower one row. The amount of lines above can change daily and above are both empty and filled cells. So i "access" the cell with the code below, which brings me to lets say A60:61 selected, but neither of the commented lines achieve to increase the height of in this case A61. It's only increasing A60.
I also tried to go via .offset(1,0) but this lead to change A62.

Range("A26").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
'Rows(ActiveCell.Row).RowHeight = 25
'ActiveCell.RowHeight = 25


How do i manage to change the height of A60&A61 or even better only A61, both works but i always end up only changing A60.

Thanks in advance and kind regards
JB

JB99
08-13-2021, 07:09 AM
Update

My quick&Dirty workaround involves unmerging, select below, increase height, select above, merge.
This does the trick for now but i wuld be curious to see if there is a leaner more direct way to address such issue.

Range("A26").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.UnMerge

Selection.Offset(1, 0).Select
ActiveCell.RowHeight = 25

Selection.Offset(-1, 0).Select
Selection.Merge

Best
J

p45cal
08-13-2021, 08:35 AM
In your first message's code add
Rows(ActiveCell.Row + 1).RowHeight = 25

JB99
08-13-2021, 11:03 AM
Ouch, That simple. I tried adressing the count of range but didnt thought about + 1


Thanks alot!