Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2005
    Chicago, IL

    Unanswered: 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 13:08.

  2. #2
    Join Date
    Oct 2003
    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!

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

    How to ask a question on forums

  3. #3
    Join Date
    Feb 2004
    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts