OzGrid

How to find account number and add text

< Back to Search results

 Category: [Excel]  Demo Available 

How to find account number and add text

 

Requirement:

 

The user's project is to create a database of account numbers with their corresponding payment dates. The user want sto use a user form to enter in an account number and by pressing a command button, that entered text from the userform text box should be found (and for now) place text in the "F" column.

The user is unsure of where to go from here. The user understands how VBA finds what numbers are in my textbox, but how does the user place text in Column "F" that is in the same row as the account number that was found?

This spreadsheet is for tracking payments on accounts and ideally at the end, the user will be able to enter an account number in a userform, enter the account number and press the button to mark that account as paid for the month.

 

https://www.ozgrid.com/forum/forum/help-forums/excel-vba-macros/1204813-find-account-number-and-add-text

 

Solution:

 

Use this version of all the macros:

Code:
Private Sub CloseBtn_Click()
    Unload Me
End Sub

Private Sub CommandButton1_Click()
    TextBox1.Value = ""
    TextBox2.Value = ""
End Sub

Private Sub EnterBtn_Click()
    Dim Found As Range
    Set Found = Sheets("Sheet1").Range("B4", Range("B" & Sheets("Sheet1").Rows.Count)).Find(Me.TextBox1.Text)
    If Found Is Nothing Then
        MsgBox ("Nothing Found!")
    Else
        Sheets("Sheet1").Range("C" & Found.Row) = Found.Offset(0, -1)
    End If
    Me.TextBox1.Text = ""
End Sub

 

Obtained from the OzGrid Help Forum.

Solution provided by Mumps.

 

See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets

 

See also:

How to search ListBox as the user types in TextBox
How to find a piece of text inside cells in a range and insert a line break on its left
How to use VBA code to select if cell contains any text return text in another cell
How to crate a macro for text copy and paste in different worksheets based on a variable in Excel

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.

 

 

 


Gallery



stars (0 Reviews)