Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Examine merged cells

Status
Not open for further replies.

samiam07

Technical User
Jan 29, 2007
80
US
Is it possible to use vba/macro to examine a merged cell on a sheet and determine how many rows/columns have been merged together?

I have a d/l from a MS-SQL db that may have multiple rows for the column headers. The current macro selects the rows (i.e. A1:A4) and merges them. Now I need to do some additional formatting and need to know how many rows have been merged (i.e. above would be 3 rows)

Thanks
 




Hi,

Please post VBA macro questions in Forum707.

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
forgetting the VBA question for a moment, I urge you not to merge cells.

I hate, hate, hate merged cells. They make many things difficult. Just try selecting one of the columns in which a row has been merged. Yuck.

If you want the look of merged cells without the headaches, use Center Across Selection.

* Select the desired cells
* Go to Format > Cells
* Go to the Alignment tab
* for Horizontal, select Center Across Selection

To get the code to do that, just follow the above steps with the macro recorder on.

As Skip said, post in forum707 with further questions about VBA.

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 



I would agree with John regarding Merged Cells as a practice. They are a royal PAIN!.

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
For badder or worse than bad, that's the way the rpts have been designed and I need to work around that. I also figured out the way to do what I need.
 
-> I need to work around that

Bah. Change it. It's easily done with VBA (which you're using anyway).

Chances are very good that no one else will notice since Center Across Selection looks like a merged cell. You'll just be making life easier for anyone who deals with an electronic version of the report.

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top