If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Merging Cells via VB and Zooming

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-27-05, 11:36
Zack-Morris Zack-Morris is offline
Registered User
 
Join Date: Mar 2005
Location: Chicago, IL
Posts: 5
Merging Cells via VB and Zooming

Good Morning,

I'm currently working on a project in which I'm creating some excel reports that are built using Visual Basic. I would like to merge some of the cells in code, just to make the report look better. Does Excel have a built in VB function to merge a range of cells together? Also, is there any sort of built in function to change the zoom of a page automatically after creating a new worksheet object? My code automatically creates new worksheets as needed, and I would like them to be at a zoom level of 75% by default. Any help on either of these problems would be greatly appreciated!

[EDIT] Just figured out the cell merging, but the worksheet zooming is still not coming to me.

Last edited by Zack-Morris; 09-27-05 at 12:08.
Reply With Quote
  #2 (permalink)  
Old 09-28-05, 09:14
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
Just as a suggestion, it might be better to use Center Across Selection, rather than merged cells.
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums
Reply With Quote
  #3 (permalink)  
Old 09-30-05, 10:48
savbill savbill is offline
Registered User
 
Join Date: Feb 2004
Posts: 533
Sometimes the easiest way to get a command is to use the Macro Record function. Find it in 'Tools>Macro>Record...'

After you record an action you can stop the record and look at the results. Recording usually gives more cluttered code than you want but you can modifiy it from there to make it more concise. Use the record to 'This Workbook' or you'll have multiple workbooks generated.

Here's the zoom function
ActiveWindow.Zoom = 77

And the Horizontal Alignment. Keep in mind you will need to have a selection made or use a range statement with the HorizontalAlignment function like I'm showing here.

Range("C9:H9").HorizontalAlignment = xlCenterAcrossSelection

Like Shades said, avoid using Merged Cells, it makes it nearly impossible to sort or change column positions if you have merged cells in the worksheet.
__________________
~

Bill
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On