VB6 and Excel -- how to format a cell in Excel to merge and center  from VB6

Posted on 2008-11-12
Last Modified: 2012-06-21
Hi all

I am running a VB6 program and sending data to an Excel spreadsheet with columns in. For the header though I want to merge and centre the cells so that the title appears centrally across a row.
any help would be very much appreciated!

kind regards
Question by:dawnyanne
    LVL 6

    Assisted Solution

    Here's what you need to do:
    Assuming that objSheet is the name of Excel object in your VB6 program.
    A1:L1 is the range where you want the heading to appear. You can change it to whatever you want.

    Selection.HorizontalAlignment = xlCenter

    Open in new window

    LVL 13

    Accepted Solution


    xlsheet.Range("A7:A9").HorizontalAlignment = xlCenter

    Author Closing Comment

    Thank you so much for your help - worked an absolute treat! Really appreciated it.

    thanks again
    LVL 13

    Expert Comment


    good morning!
    I'm glad i could help..


    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
    How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
    The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
    The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

    732 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

    23 Experts available now in Live!

    Get 1:1 Help Now