Solved

Merge Cells in Excel 97

Posted on 2002-06-18
6
563 Views
Last Modified: 2012-06-27
Hello

I'm using VB to merge cells on an excel sheet:
Let's say there is a row with 6 columns and i merge the first five cells to a large cell:

objSheet.Range(objSheet.Cells(1,2), objSheet.Cells(1,5).MergeCells = True

ThenI write the values in the cells. But If I have a long text in left colspan, this text is truncated after the end of the first cell. But it shouldn't, the cells 1-5 are merged so there is plenty of room in cell2?

¦cell1¦cell2¦cell3¦cell4¦cell5¦cell6¦
 Superdubertext_as_itshouldbe     23
 Super                            23

If I click on the cell (RMB) and the 'Formating Cells' and in the window 'Alignment'. The checkmark 'Merge cells' is only grey.


Any tips?
Alesch
0
Comment
Question by:alesch
  • 3
  • 3
6 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 7088765
Hi Alesch,

Cells is used as Cells(rowindex, colindex)

so what you're merging here is

objSheet.Cells(1,2), objSheet.Cells(1,5)

row 1 column 2 till row 1 column 5

or four columns of merging done not 1-5 but 2-5

objSheet.Cells(1,1), objSheet.Cells(1,5)

this will merge 1-5

HAGD:O)Bruintje
0
 

Author Comment

by:alesch
ID: 7088845
Ok, this was a type error. Of course :
objSheet.Cells(1,1), objSheet.Cells(1,5).
Thanks

Anyway, In the Excel-Sheet isn't a thin vertical line between cell 1 and 2 like it is between two normal cells. So it looks like the merging worked (but not completely?).

Update: It works in Excel2000

Alesch
0
 
LVL 44

Accepted Solution

by:
bruintje earned 300 total points
ID: 7089085
code like this works for me in xl97

Range(ActiveSheet.Cells(1, 1), ActiveSheet.Cells(1, 5)).MergeCells = True

so i guess there something else going wrong any other code around that merge?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:alesch
ID: 7089892
Hello bruintje

Thanks for your tests. I found the error. As you said, it was in the rest of the code. The array was wrong which I wrote in the complete (merged) row.

Superdupertext_as_it, shouldbe, 23
instead of
Superdupertext_as_itshouldbe, 23

Well, three values won't fit....

Thanks
Alesch
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7089991
glad i could help, but next time instead of giving a C,

which ruins my record that's why i'm always commenting,

ask a 0-point Q in customer support to lower the points on this Q and you can give an A or even get your points all back

Brian
0
 

Author Comment

by:alesch
ID: 7090261
Oukei then........But now i don't have time for that. Let's see the next few days. But I understand you...
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

How many times recently have you prepared a presentation or emailed a document to a client and you have found that they have older versions of MS Office and they can not open the file you have prepared.  Although most visitors to this site are exper…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now