PDA

View Full Version : VBA: textbox to equal cell value



epd
02-29-2012, 06:26 PM
Hi guys,
i am having trouble coding this bit

what i want
*user manually selects cell
*click button (shape) in excel that opens userform9
*hit "select" button in userform9
*row that contains selected cell is selected
*userform9 closes
*userform8 opens
*userform8 has 6 text boxes
*i want the 6 text boxes to be filled out with what is in certain cells that are int he selected row, ie:
textbox1 = col H with selected row
textbox1 = col N with selected row
textbox1 = col P with selected row
textbox1 = col Q with selected row
textbox1 = col R with selected row
textbox1 = col S with selected row

what i have
*user manually selects cell then clicks excel button (working)
*link from excel button to userform9 (working)
code


Sub Rectangle10_Click()
'Promt
UserForm9.Show
End Sub

*hit select button on userform9 to select row (working)
code

Private Sub CommandButton1_Click()
'Select row containing drawing number
Selection.EntireRow.Select

'Close Userform9
Unload UserForm9

'Promt
UserForm8.Show

End Sub
Private Sub CommandButton2_Click()
'Close Userform9
Unload UserForm9
End Sub
*userform8 opens and text boxes to show cells vaules (not working)
code

Private Sub UserForm_Activate()
'Select row containing drawing number
TextBox1.Text = cell(.row,H)
TextBox2.Text = cell(.row,n)
TextBox3.Text = cell(.row,p)
TextBox4.Text = cell(.row,q)
TextBox5.Text = cell(.row,r)
TextBox6.Text = cell(.row,s)

End Sub
Private Sub CommandButton2_Click()
'Close Userform8
Unload UserForm8
End Sub


what am i supposed to do here?

thanks for your help

epd
02-29-2012, 07:21 PM
i have now cutout the userform 9

code now reads

Sub Rectangle10_Click()
'Promt
UserForm8.Show
End Sub


userform8

Private Sub UserForm_Activate()
'Select row containing drawing number
Selection.EntireRow.Select

'Exisiting textbox fillout
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = "Name"
TextBox8.Text = "DD.MM.YYYY"
TextBox9.Text = "Name"
TextBox10.Text = "DD.MM.YYYY"
TextBox11.Text = "Name"
TextBox12.Text = "UNKNOWN"
TextBox13.Text = "Name"
TextBox14.Text = "DD.MM.YYYY"

End Sub

'End Sub
Private Sub CommandButton2_Click()
'Close Userform8
Unload UserForm8
End Sub

epd
03-01-2012, 04:43 PM
sorted it out

Private Sub UserForm_activate()

'Select row based on cell selection
Selection.EntireRow.Select

'TextBox and ComboBox Fillouts
'TextBox1
TextBox1.Text = ""

'TextBox2
TextBox2.Text = CStr(Selection("14").Value)

'TextBox3
TextBox3.Text = CStr(Selection("16").Value)

'TextBox4
TextBox4.Text = CStr(Selection("17").Value)

'TextBox5
TextBox5.Text = CStr(Selection("18").Value)

'TextBox6
TextBox6.Text = CStr(Selection("19").Value)

end sub