Add text from textbox to cell based on criteria

SimondsJM

New Member
Joined
Apr 16, 2011
Messages
30
I have a Form "NewCourse" that is launched from a button "CmdANC" on a sheet "Sheet2(Vendor List)".

On this form I have a ComboBox "CBox1" that pulls its List from "Sheet2(Vendor List)" as needed. There is also a textbox "TxtBx1" that requires the user to input data to be added to "Sheet2(Vendor List)".

What I need is my Command Button "AddCourse" to look at "Sheet2(Vendor List)" in Column B for selected text in "CBox1" then drop down a row and insert a new row then add the text in "TxtBx1" to that new Rows Column C.

any help wpuld be greatly appreciated.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Code:
Private Sub AddCourse_Click()
    Dim Found As Range
    If Len(TxtBx1.Value) > 0 And Len(CBox1.Value) > 0 Then
        Set Found = Columns("B").Find(CBox1.Value, , xlValues, xlWhole, xlNext, False)
        If Found Is Nothing Then
            MsgBox "Couldn't match " & CBox1.Value, vbExclamation, "No Match Found"
        Else
            Found.Offset(1).EntireRow.Insert
            Found.Offset(1, 1).Value = TxtBx1.Value
        End If
    Else
        MsgBox "Vendor selection or vendor text is missing.", vbExclamation, "Missing Enrty"
    End If
End Sub
 
Upvote 0
Ok that works great now I need to add in some border changes to the new row, Column B and C?

I have the code for the borders just need to know where to add it in, or is there going to have to be some modifications to get it to work?
 
Upvote 0
Add it between Else and End If after the new row is inserted. One way to reference the new inserted row cells B and C...
Found.Offset(1).Resize(,2)
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,672
Members
452,937
Latest member
Bhg1984

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top