VBA to insert a userform result into a point on a sheet based on cell value

Garrix

New Member
Joined
Aug 13, 2014
Messages
28
I've been messing around with userforms and macros for a little bit but frankly I'm lost when I tried this one. I have pretty basic yes/no popups and have done macros to insert data into the next empty row, that sort of thing.

Anyways.

I have a userform that I am making using comboboxes and text entry. I would like the information in that form to eventually end up inserted as a new line below the cell that contains the same information in combobox1.

Example:

Box1 = Dog,
Box2 = Small
Text box= blahblah...

Hit the 'confirm' button and all that information is entered into the spreadsheet under the header 'Dog' (sheet will have a dozen or so headers probably)

I found tons of information on using 'next blank line' as the insert point but not much on a specific value, so I'm kind of stuck. I tried using a few different methods but always get stuck at the point where I need to tell the macro where the finished result has to go.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Normally when we say header we mean row(1) of our sheet.
And what is A Box
And what is a Textbox
Your saying you will enter a value in a Combobox on your userform and you want that value entered into a Box or a Textbox on your sheet.
 
Upvote 0
Sorry if I wasn't clear.

Basically, I want to take a variable (string) which would be chosen from a list (combobox1) and find that on my spreadsheet. Then I want to take a different variable from that userform, and paste it in a new line below that previously found cell address (inserted new line, not just below without inserting a new line).

Does that make more sense?
 
Upvote 0
So you want to click on a value in Combobox1.
And search for this value where?
See on a worksheet we have 15000 columns.
Can you explain where on the sheet we should search?
Like search column 1 or search columns 1 to 5
And then you said:
Then I want to take a different variable from that userform
Where is this value?
Do you mean you have a second comboxbox where you plan to select a value?

The script needs to know the name of the combobox

The script would need to be like this:

Search column 1 for the value chosen in Combox1 and then enter the value chosen in combobox2 and insert a entire new row.

Exact details are always needed when needing help here.
And if we are dealing with more then one sheet we need sheet names.
 
Upvote 0
Maybe something like
Code:
Private Sub CommandButton1_Click()
   Dim Fnd As Range
   With Sheets("pcode")
      Set Fnd = .Range("A:A").Find(Me.ComboBox1.Value, , , xlPart, , , False, , False)
      If Not Fnd Is Nothing Then
         Fnd.Offset(1).EntireRow.Insert
         Fnd.Offset(1).Value = Me.ComboBox2.Value
         Fnd.Offset(1, 1).Value = Me.TextBox3.Value
         Fnd.Offset(1, 2).Value = Me.TextBox4.Value
      End If
   End With
End Sub
 
Upvote 0
I'll try and go through everything so i'm clear instead of trying to use named things in excel (which i think I got wrong, and was the source of the confusion >.>).

I have a sheet with a bunch of sections, and each section has a title (it's all on a single sheet, each 'section' is basically a few rows set aside for that title).

I want to be able to use a userform popup to allow someone to place an entry in a specific section. So lets say my sections are:

Plants
Animals
Vehicles
Places

the popup would have a menu where the person could choose 'Plants,' and then fill out the text box below that in the userform, and have that information show up in between 'Plants' and 'Animals' on the sheet, in a new inserted row (or rows? if possible) after they hit the 'confirm' button.

Does that make more sense?

I've had some success making the userform and getting the data to go to the first empty row, but I haven't been able to get it to find something that the user defines in the userform, then insert a new row. Not even close to that I don't think.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,398
Messages
6,124,694
Members
449,179
Latest member
kfhw720

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