Consulting

Results 1 to 3 of 3

Thread: vba loop to find and change value in textbox on userform

  1. #1

    Question vba loop to find and change value in textbox on userform

    Well I thought this would be easy, sort of, but....

    I have a worksheet, and column A with a range of 29 cells (A2:A30) containing expense category names for a budget workbook, and range A30 is called
    "Totals" which represents the totals row that sums daily transactions. I have a userform that populates textboxes with the values in column A, but I want to exclude the value "TOTALS" or at least set its Textbox.Text = "N/A".

    This would work great if the transaction worksheet was set have no more and no less than 29 rows, but I made it so users can insert/delete rows as they wish. One user might tailor his budget workbook to track only 10 expense categories where someone else may want to track 20+; therefore the "TOTALS" row is not fixed. I tried variations of loops, arrays and such and got nowhere. I don't think it should be that difficult but I'm still new at this so thanks for patience....any help would be much appreciated.

    thanks,
    sjohnp2112

  2. #2
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    you may want to do something like this:
            For i = 2 To 30
            If Sheet1.Cells(i, "A") <> "TOTALS" Then
                ' do your stuff
            Else
                Exit Sub ' found your total, exit out
            End If
        Next I

  3. #3
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    The Bottom Cell is never considered?

    LastRow = Cells(Rows.Count, "A").End(xlUp).Row
    
    For i = 2 to LastRow - 1
    'Do your thing here
    
    
    
    Next
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •