+ Reply to Thread
Results 1 to 5 of 5

Select cell in a stepwise pattern that is either blank, or based on value in other cell

  1. #1
    Registered User
    Join Date
    09-18-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Question Select cell in a stepwise pattern that is either blank, or based on value in other cell

    Hi members,

    I was hoping someone could assist with syntax.

    I have the following code (partial snippet) which is attached to a toggle button. A stepwise pattern governed by the start day (cell "S26") and frequency day (cell "R26") determines which cells are colored & locked, and which are left blank & unlocked in the range "a1:a100".
    For example, if freqday = 3, and start day = 5, then from the 5th cell onwards (ie. cell "a5"), each 3rd cell in the range is blank & unlocked, and the cells in between are colored and locked. This repeats in a stepwise fashion, and ensures data is only entered into every 3rd cell in the column without accidental input into other cells.

    Please Login or Register  to view this content.

    Once the toggle button has been pressed, I would like two different scenarios:

    1. to select the first blank & unlocked cell in range "a1:a100" so that that cursor is reset to this position. In this example, cell "a5" would be selected, or put another way, the cell in column "A" corresponding to the startday value in cell "S26" of sheet1;

    2. to search down column A and find the first unlocked cell that contains no data, and select it.

    Many thanks,

    ZZ
    Last edited by zippityzeb; 03-26-2014 at 08:09 AM.

  2. #2
    Registered User
    Join Date
    11-13-2006
    Posts
    87

    Re: Select cell in a stepwise pattern that is either blank, or based on value in other cel

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-18-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Select cell in a stepwise pattern that is either blank, or based on value in other cel

    Hello SamT,

    Thank you for your comments. Your suggestion doesn't appear to work - not sure why you changed some of the original code ? The code I provided works as intended. To put it into context, I have given the full code below:

    Please Login or Register  to view this content.
    Thus to summarize, the toggle changes between red and green to signify the range is either locked or unlocked. (Note: if you're wondering, I wanted to use a shape as a toggle button so that I could alter its colour. The code here is adapted from a post I found - perhaps it could be more succinct, as I changed it to avoid having text being part of the toggle).

    First and foremost I need the cell selection after the toggle to be general, ie. for any combination of FreqDay and StartDay. I only gave "3" and "5" as an example in my previous post.

    I figured it reasonable to use the single line of code you suggested (rng.find(what.....) but when executed it simply throws up a msgbox with the number 400.

    So to reiterate, what I want is EITHER:

    1. after the toggle button is pressed back to the lock position, the cursor is placed in the cell corresponding to the StartDay. In other words, cell "g49" plus the StartDay integer.

    OR

    2. as mentioned previously, find the first unlocked cell in the range "g49:g188" and select it.(your line of code gives a msg box with the value "400" in it; interestingly, i tried other similar codes to find and select the first unlocked cell and they gave the same result??)

    Thanks again for any helpful advice...

  4. #4
    Registered User
    Join Date
    11-13-2006
    Posts
    87

    Re: Select cell in a stepwise pattern that is either blank, or based on value in other cel

    1. after the toggle button is pressed back to the lock position, the cursor is placed in the cell corresponding to the StartDay. In other words, cell "g49" plus the StartDay integer.
    Please Login or Register  to view this content.
    I changed your code and put it in a procedure, Sub Test(), in order to test it. Why should I set up a complete worksheet just to have a set of values for FreqDay and StartDay when the only thing I am testing is the Find...Select? Not only that but, I showed you exactly where I changed it by leaving your original code in place as comments.

    Do you see a "MsgBox "400"" in this?
    rng.Find(What:="", After:=Cells(rng(Cells(Cells.Count)))).Select
    You need to look in the rest of your code to find that MsgBox.

  5. #5
    Registered User
    Join Date
    09-18-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Select cell in a stepwise pattern that is either blank, or based on value in other cel

    Thanks kindly, the 2 following suggestions worked for me:

    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)

Similar Threads

  1. Copy down hypertext cell range pattern & cell reference formula pattern
    By Underexcelling in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-10-2014, 03:23 AM
  2. Replies: 0
    Last Post: 07-28-2006, 11:05 AM
  3. Replies: 0
    Last Post: 07-28-2006, 11:00 AM
  4. Macro to select range based on cell not being blank
    By neb in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-20-2005, 01:04 PM

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