Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel User Form

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am creating a user form to input data into an excel spreadsheet. It basically consists of a text box and several check boxes. Could someone point me in the right direction with the VBA on how to manipulate this input. I want to create a heading from the text box and a series of sub categories below, dependant upon which boxes have been checked.

Thanks in anticipation.
 
It should be straighforward enough, but can I just clarify?

A simplified version - one textbox and two checkboxes.

You want the text entered into the box to be placed on the sheet as a heading, then other 'words' placed underneath this heading according to which check boxes are selected, right?

The generation and placing of text on the sheet is easy. You just create a variable and write that to the sheet.

The main problem I can see is making sure it gets written to the corect place on the sheet - will the heading always be in the same cell, or will it vary (i.e. will you need to find the next empty cell, or something like that). You also have to then make routines to avoid overwriting existing data.

All is possible. You would collect the data as the user filled the form, and place it back to the sheet as an event on the 'OK' button, or whatever you have.

Post some more details, and perhaps let us know how competant you feel with VB, and we can give you more specific help.
 
Sorry it took me so long to respond Simon, here's where I'm at:

In the User Form I have a text box (TextBox1), a series of check boxes (ChechBox1, 2 & 3) and an execute button (CommandButton1). If somebody checks boxes 1 and 3, I want adjacent cells to be filled with the relevant text. Unfortunately this routine ends at the first false return. I realise that it’s probably obvious but could you or someone please tell me why?

Private Sub CommandButton1_Click()
Dim xxx
xxx = TextBox1.Text

If CheckBox1.Value = True Then
ActiveCell.FormulaR1C1 = "1 " & xxx
ActiveCell.Offset(1, 0).Range("A1").Select

If CheckBox2.Value = True Then
ActiveCell.FormulaR1C1 = "2 " & xxx
ActiveCell.Offset(1, 0).Range("A1").Select

If CheckBox3.Value = True Then
ActiveCell.FormulaR1C1 = "3 " & xxx
ActiveCell.Offset(1, 0).Range("A1").Select

End If
End If
End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top