+ Reply to Thread
Results 1 to 5 of 5

Column Width Macro

  1. #1
    Registered User
    Join Date
    05-13-2011
    Location
    Utah, United States
    MS-Off Ver
    Excel 2007
    Posts
    1

    Thumbs up Column Width Macro

    Please forgive me if my question sounds too much like a beginner because that's exactly what I am, a VBA beginner. I'd like to create a macro in excel for setting a column width but I am not sure how to set up the macro so that I can use it for any column and set the width for any number. When I created a macro using the good old keystrokes method, the macro made my column selection part of the macro so I could only use the macro on that certain column, and it permanently set the column width at 3 because that was the width I wanted to set the column I was using. Does anyone have an idea how I can set up this macro so it will be useful universally? I would really appreciate any help anyone can give me.

    Thanks so much

    DANIGURL

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Column Width Macro

    Hello DaniGurl & Welcome to the board,

    How about something like this...

    Select the column and then run this macro.

    Please Login or Register  to view this content.
    HTH
    Regards, Jeff

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Column Width Macro

    Why not just right-click the column(s) and select Column Width?

    @Jeffrey: should use a Single rather than a Long.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Column Width Macro

    Thanks shg,

    I see...I think

    It's not because of size limitations, it's because a single will be able to handle the decimal point. Such as if they wanted the column to be 8.34.

    Is this right?

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Column Width Macro

    Right. Excel will not, in general, set the column with to exactly what you specify, but you can have decimal widths.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1