473,545 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 25312
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
.HorizontalAlig nment = xlGeneral
.VerticalAlignm ent = 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.Applicati on xl = new Excel.Applicati onClass();

Excel.Workbook wb = xl.Workbooks.Ad d(Excel.XlWBATe mplate.xlWBATWo rksheet);

Excel.Worksheet ws = (Excel.Workshee t)wb.ActiveShee t;

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

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

range.Merge(tru e);

range.Interior. ColorIndex =36;

xl.Visible =true;

Cheers,

Kids

"Damian Arntzen" <Da***********@ discussions.mic rosoft.com> wrote in message
news:78******** *************** ***********@mic rosoft.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.Applicati on xl = new Excel.Applicati onClass();

Excel.Workbook wb = xl.Workbooks.Ad d(Excel.XlWBATe mplate.xlWBATWo rksheet);

Excel.Worksheet ws = (Excel.Workshee t)wb.ActiveShee t;

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

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

range.Merge(tru e);

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
363
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"; Excel.Workbook excelWorkbook = excelApp.Workbooks.Open("eltina.xls",0,false,5,"","",false,Excel.XlPlatform.
3
28427
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 figure it out. Here is my sample code: import win32com.client xl=win32com.client.Dispatch("Excel.Application") xl.Visible=1 wb =...
5
3029
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 cells in bold, with underlining etc. i dont understand how, but in the following code, the instruction for bold gets picked up for all the cells (even...
1
9755
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 the common "cells(x,y)" reference, where x and y are integer variables. Also, how do I verify that the cells are empty, since, according to the...
1
2377
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 what the best way of going about merging the two files together, with the old price and the new price using the ID's. The second file has a list of all...
3
1912
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 each record. I began collating the information in Excel, but found myself getting lost and even experienced major data loss on at least 2 occasions. I...
5
8766
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 re-save the files in Excel, the program works, but when I use the xls files as they were created by Spss, the program returns an error message (see...
0
2342
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 single-sheet xls files, but I agree it's nicer if the programs works in other cases too. -and no, I don't intend to use data fields. Wouldn't it be easier...
1
2503
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 decades. But individuals dropped out of the study between examinations. For instance, for the first exam there were 3,000 individuals, then for the...
0
7405
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7659
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7811
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5975
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4949
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3455
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1019
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
709
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.