Adding Data to diffrent worksheets from userform

PMRetired2012

Board Regular
Joined
Aug 6, 2019
Messages
123
I have a simple userform setup. i have written code to work on all the userform but what im havint trouble getting to work is: i have 8 diffrent worksheets that i can select what worksheet i place data into. My problem is i cant get the data to go into the first empty cell (Like A1) on the sheet i select and move on down the column as i enter new data on the sheet i select. Really what im asking i guess how do i enter data in multiple worksheets as i enter data and select the worksheet i want What i do have with the code i have written is i can get data into the first cell at the bottom of my form i have layed out on the worksheet. I will include the code i have to made that doesnt work.

Private Sub CommandButton1_Click()
TargetSheet = ComboBox1.Value
If TargetSheet = "" Then
Exit Sub
End If
Worksheets(TargetSheet).Activate
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
ActiveSheet.Cells(lastrow + 1, 1).Value = TextBox1.Value
MsgBox ("Data is added successfully")
TextBox1.Value = ""
Worksheets("Master Sheet").Activate
Worksheets("Master Sheet").Cells(1, 1).Select
End Sub
 
First i want to tell you thanks alot for helping me. there are a few more things i want help with on this file. I wanted to do it is steps.

Everything is working GREAT ! But i want to work a couple things out.

1. I want my text box 1 and combobox to be clean after i click transfer data so i can add new data.
2. would like the part of code to be taken off that says: Worksheets("Master Sheet").Activate AND Worksheets("Master Sheet").Cells(1, 1).Select
and replace with the code that will take me to the sheet i just added data to so i can see that it was entered.
I belive you can just add a couple lines of code to make this happen.

Thanks Again for all your help,

Dennis


 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
How about
Code:
Private Sub CommandButton1_Click()
   targetsheet = ComboBox1.Value
   If targetsheet = "" Then Exit Sub
   
   With Worksheets(targetsheet)
      On Error GoTo NoBlanks
      .Range("A3:A24").SpecialCells(xlBlanks)(1).Value = TextBox1.Value
      On Error GoTo 0
   End With
   Worksheets(targetsheet).Activate
   Me.ComboBox1.Value = ""
   Me.TextBox1.Value = ""
Exit Sub
NoBlanks:
   MsgBox "No more blanks in sheet " & targetsheet & " range A3:A24"
End Sub
 
Upvote 0
I decided i want to add one yes or no option button into my userform. So how do i write the code for that. what i want to do is add a name in text box 1 and select from a combo box1 then select YES or NO option boxes and put that name (Textbox 1 and Combox 1) starting with cells A35 thru A39.
so another words if i select YES on the option button it will send the info in text box1 and combox 1 to cells A3 thru A24 and if i select NO the info in text box1 and combox 1 will go into cells A35:A39.
also i want the all of the form to be cleared when i click transfer data so it will be ready for next entery.
 
Upvote 0
As this is a completely different question, you will need to start a new thread.
Thanks
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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