+ Reply to Thread
Results 1 to 12 of 12

Apply to selected columns

  1. #1
    Forum Contributor
    Join Date
    11-18-2009
    Location
    Winnipeg
    MS-Off Ver
    Excel 2003
    Posts
    203

    Apply to selected columns

    I'm using the following code to fill in blanks in a table. The table has anywhere from 1-5 columns with blanks I need to fill. Currently the code only fills in one column at a time. How do I change it so I can select a number of columns and only run the macro once?

    Please Login or Register  to view this content.

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

    Re: Apply to selected columns

    Where is the table located?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    11-18-2009
    Location
    Winnipeg
    MS-Off Ver
    Excel 2003
    Posts
    203

    Re: Apply to selected columns

    It's on one worksheet, anywhere from 3-8 columns and up to 500 rows. Not sure if that answers your question...

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

    Re: Apply to selected columns

    Is it the entire used range of the sheet?

  5. #5
    Registered User
    Join Date
    08-18-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Apply to selected columns

    Much easier way than a macro.
    Highlight your whole area
    -Edit-GoTo (or Control G)
    -Special
    -choose Blanks (all blanks are highlighted)
    Then put in what ever you want in the blanks (n/a, or whatever) and instead of pressing enter press Control Enter which will fill all blanks.

  6. #6
    Forum Contributor
    Join Date
    11-18-2009
    Location
    Winnipeg
    MS-Off Ver
    Excel 2003
    Posts
    203

    Re: Apply to selected columns

    Quote Originally Posted by kzmr1234 View Post
    Much easier way than a macro.
    Highlight your whole area
    -Edit-GoTo (or Control G)
    -Special
    -choose Blanks (all blanks are highlighted)
    Then put in what ever you want in the blanks (n/a, or whatever) and instead of pressing enter press Control Enter which will fill all blanks.
    That's what I have been doing...but when I try to train that to my folks who are not so comfortable with computers, they don't understand. I was thinking it might be easier if I had a button with the macro attached to it and all they'd have to do is highlight the columns they wanted and click the button...

  7. #7
    Forum Contributor
    Join Date
    11-18-2009
    Location
    Winnipeg
    MS-Off Ver
    Excel 2003
    Posts
    203

    Re: Apply to selected columns

    Quote Originally Posted by shg View Post
    Is it the entire used range of the sheet?
    No...it's always the first column, and usually the second and third...sometimes others, but the last 2 columns don't have any blanks.

  8. #8
    Forum Contributor
    Join Date
    11-18-2009
    Location
    Winnipeg
    MS-Off Ver
    Excel 2003
    Posts
    203

    Re: Apply to selected columns

    Ok so i just recorded a macro of the Edit > GoTo function...I don't know if that's the same thing as the macro I had copied, but it seems to work....

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

    Re: Apply to selected columns

    My question is, how is the code supposed to know the extents of the table?

    You can apply the method to the selection, or the current region of the selection, or the current region of some particular cell that's always in the table, or to a named range, or to the used range, or to ....

  10. #10
    Forum Contributor
    Join Date
    11-18-2009
    Location
    Winnipeg
    MS-Off Ver
    Excel 2003
    Posts
    203

    Re: Apply to selected columns

    Quote Originally Posted by shg View Post
    My question is, how is the code supposed to know the extents of the table?

    You can apply the method to the selection, or the current region of the selection, or the current region of some particular cell that's always in the table, or to a named range, or to the used range, or to ....
    Yes, I guess I was picturing it applying to a selection...which is what I thought this code was doing, but it will only do one column at a time, even if I have multiple columns selected. I'm really new to VBA (is it obvious???) so I don't know how to read it to troubleshoot.

  11. #11
    Registered User
    Join Date
    08-18-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Apply to selected columns

    As long as the cells were highlighted before the macro was run...and...your people know to highlight their cells in the area before running the macro.

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

    Re: Apply to selected columns

    Try this:
    Please Login or Register  to view this content.

+ 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