+ Reply to Thread
Results 1 to 9 of 9

Find active cell location based on column heading and cell value

  1. #1
    Registered User
    Join Date
    05-19-2023
    Location
    Indianapolis, IN
    MS-Off Ver
    Microsoft 365 for Enterprise
    Posts
    11

    Find active cell location based on column heading and cell value

    So, I have mapped the different areas of our lab space on different tabs (in the attached file I have narrowed it down to 1 lab space for the sake of file size). What I would like to do is to create a command button for equipment search (shown on the SEARCH tab). Ideally I would like to select the lab and location from separate drop down menus (E4 and F4 respectively). Once those are selected, the user would then click on the "Then Click Here!" Command button. Clicking the command button should activate a sub to find the sheet (listed in E4) and the location (listed in F4) in the table named Map and activate that sheet and cell. For example, if I select QC lab location B, the sub should look at the Map table, find the value of the cell in the that corresponds to Column.Row = QC lab.B. The sub should then activate the QC lab sheet and activate the cell it found at QC lab.B (cell in this case is AM32).

    TIA!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,673

    Re: Find active cell location based on column heading and cell value

    Please Login or Register  to view this content.
    "Location_tbl","Labs","Locations" are named ranges
    Attached Files Attached Files
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Registered User
    Join Date
    05-19-2023
    Location
    Indianapolis, IN
    MS-Off Ver
    Microsoft 365 for Enterprise
    Posts
    11

    Re: Find active cell location based on column heading and cell value

    Works great on the example, but the below line causes a Run-time error "1004" Method "Range" of object "_Worksheet" failed.

    cell = Application.Index(Range("Location_Tbl"), Application.Match(location, Range("Locations"), 0), Application.Match(Lab, Range("Labs"), 0))

    I don't see where Location_Tbl is named as a range. Could that be my problem?

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,673

    Re: Find active cell location based on column heading and cell value

    Look under Formulas>>Name Manager where you will see the named ranges defined: you need to do the same in your actual w/book.

  5. #5
    Registered User
    Join Date
    05-19-2023
    Location
    Indianapolis, IN
    MS-Off Ver
    Microsoft 365 for Enterprise
    Posts
    11

    Re: Find active cell location based on column heading and cell value

    OK, so I created the named ranges Locations, Labs, and Location_Tbl, but now I am getting a type mismatch error for the same line.

  6. #6
    Registered User
    Join Date
    05-19-2023
    Location
    Indianapolis, IN
    MS-Off Ver
    Microsoft 365 for Enterprise
    Posts
    11

    Re: Find active cell location based on column heading and cell value

    Looking at it further, the code given has the same type mismatch error when a location is selected that is not valid for the lab. I tried QC Lab at Location 23 (which doesn't exist) and got the type mismatch error. I think it may be related to the blanks in the Location_Tbl?

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,673

    Re: Find active cell location based on column heading and cell value

    Please Login or Register  to view this content.
    Last edited by JohnTopley; 02-16-2024 at 06:29 PM.

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,673

    Re: Find active cell location based on column heading and cell value

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by JohnTopley; 02-17-2024 at 03:50 AM. Reason: Update to macro

  9. #9
    Registered User
    Join Date
    05-19-2023
    Location
    Indianapolis, IN
    MS-Off Ver
    Microsoft 365 for Enterprise
    Posts
    11

    Re: Find active cell location based on column heading and cell value

    Bless you! It works wonderfully! Thank you so much!

+ 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. [SOLVED] Creating a macro that will format a group of cells based on the location of active cell
    By oceaneagle04 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-15-2022, 01:49 PM
  2. Looking up a column heading based data in a cell
    By carlzoll in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-14-2018, 03:11 PM
  3. Using offset function to select a range of cells based on active cell location
    By laxminarayana in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-25-2017, 07:49 AM
  4. [SOLVED] VBA to find the nearest empty cell in column F and use that as the active cell.
    By oneblondebrow in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-24-2017, 11:55 AM
  5. Delete a column based on a heading cell value and loop
    By hassan88 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-03-2015, 07:42 AM
  6. Replies: 2
    Last Post: 06-08-2011, 02:36 PM
  7. Select a Range Based on Active Cell Location?
    By w01f in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-27-2009, 08:35 AM

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