Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() More about properties... Start thinking in objects when you build something like this. So your worksheet is an object, in the workbook object. The button is an object on your worksheet, etc. When programming, it is the best to use objects instead of full workbooknames or sheetnames. After you clicked the button, the form shows up, so far so good. Remember, on the form object, there are textbox objects, combobox objects, etc. To transfer data from your form to your worksheet, you should transfer data from one object to the other. Let's do this after a button on the form called 'buttonPopulate' is clicked. Private Sub buttonPopulate_Clicked() 'Declare object variabeles Dim wb as WorkBook Dim ws As WorkSheet Set wb = ThisWorkBook Set ws = wb.Sheets("Sheet1") 'Now I can say ws.Cells(1,1) for A1, instead 'of 'ThisWorkbook.Sheets("Sheet1").Cells(1,1) 'so writing in objects is way shorter 'Activate the worksheet to enter form data ws.Activate 'Transfer form data... ws.Cells(1,1).Value = Me.TextBox1.Text '...will put the text in TextBox1 in cell A1 'Me is the form object, Text is a so called property of the TextBox object 'This way you can walk through all your controls 'and move data to any cell address you want 'If you're done, always clean up your objects Set ws = Nothing Set wb = Nothing End Sub "maximillan" <u25565@uwe schreef in bericht news:651cec8556490@uwe... Hello, I've just started using Excel VBA. I've a little background on programming VBA and I do mean "little". Anyway, I've been looking all over about how to transfer data from UserForm in Excel VBA to a worksheet. Problem is, I've still not grasped the idea nor understand the codes posted here. So if anyone can help me with this and explain as simple as possible on how to do this, please do so. What I did so far: Created a command button in the worksheet with the code: Reg_Frm.Show < Which opens the UserForm Then designed the UserForm with the following items: 3 Text Boxes 1 Combo Box (Not bound. Used ComboBox1.additem) 1 Quit button (Functional) 1 Reset button (Functional) 1 submit button (Problem) I intend to fill a row with the data taken from UserForm but don't know where to start. Also, if possible, someone explain to me how it'll check if the cell is vacant or not. I'm a complete noob when it comes to macros just so you know. Thank you in advance for the help. ^__^ |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Data from userform to worksheet | Excel Programming | |||
Data from userform to worksheet | Excel Programming | |||
data from userform into worksheet cells | Excel Programming | |||
Populate Userform text boxes in VBA with VLookup data from #2 worksheet | Excel Programming | |||
Taking Data of cell from worksheet to a userform window | Excel Programming |