+ Reply to Thread
Results 1 to 5 of 5

Macro - Conditionally Define a Range

  1. #1
    Registered User
    Join Date
    06-04-2013
    Location
    COlumbus, OH
    MS-Off Ver
    Excel 2003
    Posts
    6

    Macro - Conditionally Define a Range

    Hello,

    I am still quite new to the VBA world. I have a spreadsheet in which on worksheet 2 ("Forms") I have a macro that will draw checkboxes (and link them to the same cell) based on the range you give it. So, for example, I have:

    Please Login or Register  to view this content.

    The Macro itself works fine when you take the time to define the range. The gaps are for rows that are intentionally left blank (for the sake of organizing) and don't need checkboxes.

    So what I am looking to do is to have the macro figure out which rows need checkboxes in columns G-N based on whether or not there is content in column F which has text in (or not if it is a blank row).

    Problem is, I have no clue where to start here on changing the the Range section ("For Each myCell In .Range...

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Macro - Conditionally Define a Range

    well, you could just add some logic to check for content in column F.

    Please Login or Register  to view this content.

    i'm not really sure what you are doing with the Set myCBX statement, but if you want it to only happen if the F column has content (on that row) you should be able to just add that check making use of "myCell.row"
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  3. #3
    Forum Contributor vikas.bhandari's Avatar
    Join Date
    04-07-2006
    Location
    Delhi, India
    MS-Off Ver
    Office 2007 and 2010
    Posts
    303

    Re: Macro - Conditionally Define a Range

    Change this:

    Please Login or Register  to view this content.
    to:

    Please Login or Register  to view this content.

    Does it help?

  4. #4
    Registered User
    Join Date
    06-04-2013
    Location
    COlumbus, OH
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro - Conditionally Define a Range

    Ok that didn't really work so I am including the entire code... (i emailed it to myself hence the partial code above)

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-04-2013
    Location
    COlumbus, OH
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro - Conditionally Define a Range

    Nevermind, got it with GeneralDisarray's post

    THANKS!

+ 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