+ Reply to Thread
Results 1 to 4 of 4

Idenitfy column based on value entered in textbox for specific range

  1. #1
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Idenitfy column based on value entered in textbox for specific range

    Hi everyone,

    I have the following code:
    Please Login or Register  to view this content.
    This code works just fine. However, in order for me to run the code on different columns of data, I need to adjust the target column directly in the code here (i.e. "AF" and "AF1:AF"):

    Please Login or Register  to view this content.
    What I'm trying to do is be able to identify the column to run the code on based on a numerical value entered in textbox SP_V. This value will then search range W1:AD1 in sheets("Master"), and when it finds it, the code will run in the column that contacted that numerical value in row 1.

    Any ideas?

    Thanks!

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,910

    Re: Idenitfy column based on value entered in textbox for specific range

    It looks like if you converted your data range to an Excel Table, a lot of your problem will go away. Some of the advantages of Excel Tables is that they know how big they are and that you can use column headers in the formulas an VB Code. So suppose column AE is Company and Column AF is Contact Name then the list of Contact Names is Table_Name[Contact Names]. You want to count them? =Counta(Table_Name[Contact Names]. You want to look at them in VBA?
    Please Login or Register  to view this content.
    And you can do things like
    Please Login or Register  to view this content.
    which sounds like the kind of thing you want to do.

    Here is some more information on Excel Tables: http://www.utteraccess.com/wiki/inde...ables_in_Excel.

    If you have issues, include a sample workbook and I can help you get started.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Idenitfy column based on value entered in textbox for specific range

    HI dlfak,

    Thanks very much for your reply. What I'm not certain of is how to call the table range that's been entered into a textbox using the code you gave me. This is what I have so far:

    Please Login or Register  to view this content.
    SP_V is the name of the textbox that the user will enter the table range name in. How can I get the macro to run all cell values in that table range entered from the textbox?

    Thanks for your help!!

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,910

    Re: Idenitfy column based on value entered in textbox for specific range

    It would help a lot if you can post a sample workbook with non-sensitive data. It would make seeing the requirement easier.

+ 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. Replies: 13
    Last Post: 05-02-2016, 06:03 AM
  2. Filter ListbBox based on string entered in TextBox
    By aimz_eyana in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-22-2015, 09:16 PM
  3. [SOLVED] VBA Finding next empty row if value in specific textbox entered
    By achishti in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 02-25-2015, 07:43 AM
  4. [SOLVED] Trying to move specific range to a specific sheet based on data in certain column
    By cain2011 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-01-2013, 08:09 AM
  5. [SOLVED] how to stop Command button If specific number is entered in a specific cell range
    By sspreyer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-26-2013, 05:10 AM
  6. Display msgbox when specific text entered in specific range
    By Ali_Riza in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-20-2012, 08:05 AM
  7. Replies: 15
    Last Post: 10-11-2009, 11:46 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