+ Reply to Thread
Results 1 to 10 of 10

Finding the nth non empty cell in a row and returning value to text box vba

  1. #1
    Registered User
    Join Date
    05-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Finding the nth non empty cell in a row and returning value to text box vba

    Hey everyone,

    I have a userform that has 7 fields that are connected to an autofilter. On the click of a button it filters the data. I also have 16 other text boxes that will be used to reference data from the resultant row from the filter.

    The following image displays the data prior to the filter.
    Notes_Grid1.PNG

    This image shows the userform with the autofilter data field in. The combo boxes on the left are linked to the filter. The text boxes on the right are linked to the non-contiguous non blank cells adjacent to column G.

    NotesPic.PNG

    Also attached is an image showing the filtered data if that helps.

    The text box with WC1 as the label will be the column header of the data in the first non blank cell and the data of the first non blank cell will be in the text box below that one. The text box with WC2 as the label will contain the column header of the second non blank cell and the text box below it will contain the data from the 2nd cell with data, and so on.

    I've researched several approaches, but they all seem to be using the index function which is not compatible with VBA. If you need the actual file or current code, let me know.

    In a way, it would be treated like an Access database and linking the remaining relative data in the row.

    Thanks in advance,
    Jimalya
    Attached Images Attached Images
    Last edited by jimalya; 07-22-2013 at 04:36 PM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Finding the nth non empty cell in a row and returning value to text box vba

    jimalya,

    Its hard to say without seeing your code, but hopefully you can adapt something like this. Note that the code assumes your textboxes have a naming convention. The 'WC' textboxes that will hold the header are assumed to be named 'txtWC#' where # is 1, 2, ...8, and that the textboxes that will hold the notes are named 'txtWC#Note' where # is again 1, 2, ...8
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    05-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Finding the nth non empty cell in a row and returning value to text box vba

    Thanks tigeravatar! I'll give it shot.

  4. #4
    Registered User
    Join Date
    05-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Finding the nth non empty cell in a row and returning value to text box vba

    Hey tigeravatar,
    I'm getting an object variable not set in this line:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Finding the nth non empty cell in a row and returning value to text box vba

    Here's my entire code if this helps.


    Please Login or Register  to view this content.

  6. #6
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Finding the nth non empty cell in a row and returning value to text box vba

    jimalya,

    In your userform you have a textbox that display what record the user is currently viewing ('1 of 3', '2 of 3', etc). You also have Previous and Next buttons which either are not yet coded or you did not provide their codes. I have assumed that the textbox displaying what record the user is currently viewing (the 1, 2, etc) is named txtActiveRecord, so you'll need to adjust the code to the correct name for that textbox.

    With that adjustment, this should work for you (this is the CommandButton1_Click code):
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Finding the nth non empty cell in a row and returning value to text box vba

    Wow! That is perfect.

    You are correct, I haven't coded that yet, but thanks for knocking that part out for me. That's great and it works just like it should. Would you happen to know how to add the previous and next functionality off the top of your head? If not, that's fine because you've helped out tremendously! However if you can, the buttons are btnPrevious and btnNext. Wow, I'm amazed.

  8. #8
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Finding the nth non empty cell in a row and returning value to text box vba

    jimalya,

    They would be very simple.
    btnPrevious:
    Please Login or Register  to view this content.

    btnNext:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Finding the nth non empty cell in a row and returning value to text box vba

    You are a magician wise one. Thank you so much. You've been a great help!!

  10. #10
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Finding the nth non empty cell in a row and returning value to text box vba

    You're very welcome

+ 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. finding a text string and returning a Y or N
    By wilksy in forum Excel General
    Replies: 3
    Last Post: 05-11-2011, 03:38 AM
  2. finding max value and returning text in different column same row
    By Mark6277 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-10-2009, 01:18 PM
  3. Replies: 6
    Last Post: 07-15-2009, 07:44 AM
  4. Finding text in a list, and returning the row next to it.
    By Hejl82 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-22-2008, 02:26 PM
  5. [SOLVED] Finding next empty empty cell in a range of columns
    By UncleBun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-13-2006, 07:25 PM

Tags for this Thread

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