473,416 Members | 1,498 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Merging Cells in Excel 2003

I'm a beginner to moderate programmer who's fiddling around with automating
Excel, in particular after being able to have the user fill out a form and it
then generate the workbook. I can't quite figure out how to get it to Merge
cells together - I've found how to do it (I think) but can't nut out the
syntax. Any help with this would be much appreciated (I've tried looking for
online tutorials, but the ones I've found never touch merging).

Cheers,
Damian A.
Nov 16 '05 #1
3 25304
A trick I learned that works with most Microsoft products is to go to
Tools->Macros->Record->Record New Macro and then do whatever you are trying
to figure out what to do. When you view the macro, you then have the sytax. I
don't have .Net at home (so it's in VB, sorry), but try something like this:

Range("A1:B1").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With

I hope this helps.
Susan
"Damian Arntzen" wrote:
I'm a beginner to moderate programmer who's fiddling around with automating
Excel, in particular after being able to have the user fill out a form and it
then generate the workbook. I can't quite figure out how to get it to Merge
cells together - I've found how to do it (I think) but can't nut out the
syntax. Any help with this would be much appreciated (I've tried looking for
online tutorials, but the ones I've found never touch merging).

Cheers,
Damian A.

Nov 16 '05 #2
Hi Damian A.

Try this out.

Excel.Application xl = new Excel.ApplicationClass();

Excel.Workbook wb = xl.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorkshe et);

Excel.Worksheet ws = (Excel.Worksheet)wb.ActiveSheet;

ws.Cells[1,1] = "Testing";

Excel.Range range = ws.get_Range(ws.Cells[1,1],ws.Cells[1,2]);

range.Merge(true);

range.Interior.ColorIndex =36;

xl.Visible =true;

Cheers,

Kids

"Damian Arntzen" <Da***********@discussions.microsoft.com> wrote in message
news:78**********************************@microsof t.com...
I'm a beginner to moderate programmer who's fiddling around with automating Excel, in particular after being able to have the user fill out a form and it then generate the workbook. I can't quite figure out how to get it to Merge cells together - I've found how to do it (I think) but can't nut out the
syntax. Any help with this would be much appreciated (I've tried looking for online tutorials, but the ones I've found never touch merging).

Cheers,
Damian A.

Nov 16 '05 #3
Just tried it out - Works a wonder. I was close, but I guess thats the
trouble with teaching yourself - Tis a wee bit harder than normal. Thanks!

"kids_pro" wrote:
Hi Damian A.

Try this out.

Excel.Application xl = new Excel.ApplicationClass();

Excel.Workbook wb = xl.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorkshe et);

Excel.Worksheet ws = (Excel.Worksheet)wb.ActiveSheet;

ws.Cells[1,1] = "Testing";

Excel.Range range = ws.get_Range(ws.Cells[1,1],ws.Cells[1,2]);

range.Merge(true);

range.Interior.ColorIndex =36;

xl.Visible =true;

Cheers,

Kids

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: David Krmpotic | last post by:
hi!! I use the following code to operate excel document: Excel.Application excelApp = new Excel.ApplicationClass(); //excelApp.Visible = true; string workbookPath = "c:\\eltina.xls";...
3
by: zxo102 | last post by:
Hi there, I need your help for python <--> excel. I want to paste selected cells (range) to different location on the same sheet in Excel through python. I have tried it for a while but could not...
5
by: mrid via DotNetMonster.com | last post by:
hi. im exporting data from a vb form to excel. i am able to create a new excel file, save and edit it without any trouble, but the formatting is giving me hell! i need to be able to show certain...
1
by: mgoold2002 | last post by:
I'm moving some code from Excel vbs into a .NET context and I'm very new to .NET. I'm trying to make this Excel vb code work in .NET. My questions are: how do I reference cells correctly using...
1
by: adamrace | last post by:
Hi, I've got two excel files, one has a list of products and their current prices and they all have a product ID, I have another file with a list of price's that need updating. I was wondering...
3
by: bazdaa | last post by:
Access 2K3 Append/Update ignore non null cells! Hi, I have been tasked with completing an audit of approximately 10,000 items, to which I have generated a list of 40 questions (fields) for...
5
by: Albert-jan Roskam | last post by:
Hi, I wrote the program below to merge all xls files in a given directory into one multisheet xls file. It uses xlwt and xlrd. The xls files I use for input are generated by Spss. When I open and...
0
by: Albert-jan Roskam | last post by:
Hi John, Thanks! Using a higher xlrd version did the trick! Regarding your other remarks: -yep, input files with multiple sheets don't work yet. I kinda repressed that ;-) Spss outputs only...
1
by: BBMcL | last post by:
Advanced thanks for any helping. I'm running Python on a Mac OS X. Here's the basic situation. A single group of people had various health measurements performed on them over the course of a few...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.