VBA form data to specific cells

MNFPGE

New Member
Joined
Mar 5, 2018
Messages
13
Hi, I'm new to forms and a beginner on VBA, so struggling with a VBA to make a user form fill in specific cells in a sheet. I have created the form and now I want to get the data from the fields into the cells on the worksheet and if the cells in the worksheet have data in them for this to be shown in the form fields. I have set up a button in the worksheet to show the userform and I want a button on the userform to save the workbook once the fields have been filled in. Not all the fields will have data in them. I also want a button to close the form once the user has finished. Below shows the location I want the data to end up(Column C) and the names of the fields(Column B) in the form. I haven't really got any VBA so far that is worth posting as I'm lost to start with!:eek:


Cell Formulas
RangeFormula
B83Rail Wall 1
B84Rail Wall 2
B85Rail Wall 3
B86Left Wall 1
B87Left Wall 2
B88Left Wall 3
B89Right Wall 1
B90Right Wall 2
B91Right Wall 3
B92Opp Wall 1
B93Opp Wall 2
B94Opp Wall 3
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Well to close a Userform you need a button on the Userform
And the code:
Unload Me

To send data to the sheet you would need code like this:

Sheets(1).cells(1,1).value=Textbox1.value

This is a simplistic answer.

You would need to modify to your needs.
 
Upvote 0
Thanks My Aswer Is This and James 006. Working through what you have both posted and hopefully I'll get it. Good learning's anyway!
 
Upvote 0
Ok, so here's what I've come up with, I've kept it brief until I get it working. It opens and closes the form alright but doesn't unload the data into the worksheet. I'm obviously missing something but I'm not sure what...

Code:
Private Sub CarWallBraceUserForm()

UserForm3.Show


End Sub
Private Sub SaveWallBraceButton_Click()
Dim WS As Worksheet
Dim Sizes As Long
Set WS = Worksheets("Questions")
With WS
Sheet("Questions").Cells(85, 3).Value = RailPosn1.Value
Sheet("Questions").Cells(86, 3).Value = RailPosn2.Value


End Sub


Private Sub CloseFormBtn_Click()
Unload Me
End Sub
 
Upvote 0
How about
Code:
Private Sub SaveWallBraceButton_Click()
   Dim WS As Worksheet
   Dim Sizes As Long
   Set WS = Worksheets("Questions")
   With WS
      .Cells(85, 3).Value = RailPosn1.Value
      .Cells(86, 3).Value = RailPosn2.Value
   End With

End Sub
 
Upvote 0
Thanks Fluff, tried that but it doesn't work either. I'm not sure if I've got something simple wrong, like Text Box names but I've checked them so it's not them. Is there something else obvious that I've missed? Thanks again.
 
Upvote 0
That code should be putting the values from the textboxes into C85 & C86 on the Questions sheet.
Do you get any error messages?
 
Upvote 0
The form opens, but the data doesn't unload to the cells.
Code:
Private Sub CarWallBraceUserForm()

UserForm3.Show


End Sub
Private Sub SaveWallBraceButton_Click()
   Dim WS As Worksheet
   Dim Sizes As Long
   Set WS = Worksheets("Questions")
   With WS
      Cells(85, 3).Value = RailPosn1.Value
      Cells(86, 3).Value = RailPosn2.Value
   End With


End Sub


Private Sub CloseFormBtn_Click()
Unload Me
End Sub


Private Sub UserForm_Click()


End Sub
 
Upvote 0

Forum statistics

Threads
1,213,501
Messages
6,114,010
Members
448,543
Latest member
MartinLarkin

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