+ Reply to Thread
Results 1 to 6 of 6

VBA to match in a loop and use the match

  1. #1
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    VBA to match in a loop and use the match

    So the best way to explain this, is I have a formula that outputs the headers of various columns (basically checking for discrepancies). The entire sheet is locked for editing. When one of the cells in this helper column are equivalent to a header, I'd like the code to unlock that entire column, minus the header and anything above it. The difficult part is that I don't know which "column" will be displayed in my helper column when I run the code.

    My Headers are in row 5, and I'd like them + anything above it to remain locked. It should only display one header at a time, but it will probably be in multiple locations at once.

    I've attempted this for quite a while, but am really scratching my head on it...

    you can match it with "* column" but that's about as far as I've gotten. I can't figure out how to go from the * to a specific column. It is beyond my level at the moment (just starting VBA).

    I'll attach a sample file (no formulas, just to give you an idea of the layout).

    EDIT:
    An idea just came to me (not sure how efficient it is). We could possibly filter by the helper column by "* column" then match the visible data with a header column. I know how to do it in words, but VBA is a totally different story.

    This is what I have so far on that...

    Please Login or Register  to view this content.
    Any help greatly appreciated, especially if you explain the code so I can learn from it.
    Attached Files Attached Files
    Last edited by TheN; 11-18-2016 at 06:23 PM. Reason: More info on an idea

  2. #2
    Forum Contributor
    Join Date
    07-23-2016
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    273

    Re: VBA to allow/disallow editing in certain cells (via helper column)

    You should look up how to protect and unprotect worksheets as well as how to lock/unlock cells. You can loop through the column cells unlocking them; (1) Unprotect the worksheet, (2) set the cells you want to be unlocked, (3) protect the worksheet.

  3. #3
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: VBA to allow/disallow editing in certain cells (via helper column)

    I understand that part it is the matching part I am confused about. I don't know how to write something testing for a match then do this.

    Basically if criteria
    Then do
    Unlock
    End do

    I didn't really see anything demonstrating that.

    Also is filtering and looking at visible data an efficient way to find my match criteria?

  4. #4
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: VBA to allow/disallow editing in certain cells (via helper column)

    So can anyone help?

    I am basically looking for help with the matching part, and its syntax. I am capable of writing the code to lock/unlock and all that on my own (setting the areas, all that good stuff).

    If we are going with my method (which may or may not be the most efficient) I would need it to say something like:

    If FirstVisibleData = HeaderRange

    What I really need is the part highlighted in red especially the header range part, unsure how to test against multiple things and store the match value.

    Please Login or Register  to view this content.
    Thanks in advance, as always.

  5. #5
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: VBA to allow/disallow editing in certain cells (via helper column)

    So, I am still quite confused about how to go about "matching" my Criteria (storing the first visible filtered data) with the column headers, then determining what column to unlock from the cell address. After the first match, it can exit the testing loop if that helps...

    I've done quite a bit of research but haven't really found anything adaptable to my problem.

  6. #6
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: VBA to match in a loop and use the match

    Better title now, hopefully that illustrates where I am still stuck. You'd think something like matching would be easy to find on google, but I can't find anything I can adapt to this... (It's probably very simple for someone out there).


+ 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. Sort by helper column even if values in helper are alike
    By NoSleepForMe in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-10-2016, 04:14 AM
  2. Helper column to only show name
    By zplugger in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-17-2015, 08:52 AM
  3. [SOLVED] Week No. Vs.Value without Helper cells in Column E
    By thilag in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-12-2013, 04:31 AM
  4. Editing all the cells in a column
    By eileen2006 in forum Excel General
    Replies: 2
    Last Post: 08-28-2008, 10:26 PM
  5. [SOLVED] help creating helper column
    By Allen Clark in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2006, 12:20 AM
  6. Disallow File Save if No Input in Cells?
    By Dan Raab in forum Excel General
    Replies: 2
    Last Post: 01-09-2006, 02:40 PM
  7. [SOLVED] What is a helper column?
    By RMPPOD in forum Excel General
    Replies: 3
    Last Post: 01-28-2005, 04:06 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