Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Radio Button
Hi
I have a form with 2 radio buttons; one for Laptop 1 and the other for Laptop 2. Also on the form are some text input fields which is generic to both laptop 1 and 2. My question is, based on the radio button selected, i'd like to copy the information entered into the text fields on the form to the respective worksheet (worksheet Laptop 1 or worksheet Laptop 2). I'm not sure how to say If radio button 1 is selected,then write the info to worksheet Laptop 1 or If radio button 2 is selected then write the info to worksheet Laptop 2. I look forward to any help. Thank you |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Radio Button
Put this in the UserForm code module.
Private Sub OptionButton1_Click() If Me.OptionButton1 = True Then Sheets("Laptop 1").Activate End If End Sub Private Sub OptionButton2_Click() If Me.OptionButton1 = True Then Sheets("Laptop 2").Activate End If End Sub "zak" wrote: Hi I have a form with 2 radio buttons; one for Laptop 1 and the other for Laptop 2. Also on the form are some text input fields which is generic to both laptop 1 and 2. My question is, based on the radio button selected, i'd like to copy the information entered into the text fields on the form to the respective worksheet (worksheet Laptop 1 or worksheet Laptop 2). I'm not sure how to say If radio button 1 is selected,then write the info to worksheet Laptop 1 or If radio button 2 is selected then write the info to worksheet Laptop 2. I look forward to any help. Thank you |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Radio Button
Had a typo in the first one. Use this set of code.
Private Sub OptionButton1_Click() If Me.OptionButton1 = True Then Sheets("Laptop 1").Activate End If End Sub Private Sub OptionButton2_Click() If Me.OptionButton2 = True Then Sheets("Laptop 2").Activate End If End Sub "zak" wrote: Hi I have a form with 2 radio buttons; one for Laptop 1 and the other for Laptop 2. Also on the form are some text input fields which is generic to both laptop 1 and 2. My question is, based on the radio button selected, i'd like to copy the information entered into the text fields on the form to the respective worksheet (worksheet Laptop 1 or worksheet Laptop 2). I'm not sure how to say If radio button 1 is selected,then write the info to worksheet Laptop 1 or If radio button 2 is selected then write the info to worksheet Laptop 2. I look forward to any help. Thank you |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Radio Button
Hi zak,
Let me put in steps what you should do. I hope this will help 1. Put a Button control on the Userform 2. Name the Button BtnSaveInfo 3 Change the Caption of the button to something descriptive maybe 'Save' or 'Save Info' 4. Double click the button 5. enter the follwing code in step 6 between the follwing code lines Private Sub BtnSaveInfo_Click() End Sub 6. Code to enter behind the button Dim Sht As Worksheet If OptionButton1.Value = True Then Set Sht = ThisWorkbook.Worksheets("Laptop1") Else Set Sht = ThisWorkbook.Worksheets("Laptop2") End If Sht.Range("A1").Value = TextBox1.Text Hope this helps, -- A. Ch. Eirinberg "zak" wrote: Hi I have a form with 2 radio buttons; one for Laptop 1 and the other for Laptop 2. Also on the form are some text input fields which is generic to both laptop 1 and 2. My question is, based on the radio button selected, i'd like to copy the information entered into the text fields on the form to the respective worksheet (worksheet Laptop 1 or worksheet Laptop 2). I'm not sure how to say If radio button 1 is selected,then write the info to worksheet Laptop 1 or If radio button 2 is selected then write the info to worksheet Laptop 2. I look forward to any help. Thank you |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Radio Button
Thank you both for your responses. Your code has been a great help! Thank you
I have now got it to work, but have another relating question. Please see my code below and let me know how i can say to add a new row everytime the form is used and not just rewrite over A5,B5,C5,D5 etc. Private Sub BtnSaveInfo_Click() Dim Sht As Worksheet If Laptop1.Value = True Then Set Sht = ThisWorkbook.Worksheets("Demo Laptop 1") Sht.Range("A5").Value = TextBox2.Text Sht.Range("B5").Value = RecDate.Text Sht.Range("C5").Value = RSVers.Text Sht.Range("D5").Value = CachVers.Text End If If Laptop2.Value = True Then Set Sht = ThisWorkbook.Worksheets("Demo Laptop 2") Sht.Range("A5").Value = TextBox2.Text Sht.Range("B5").Value = RecDate.Text Sht.Range("C5").Value = RSVers.Text Sht.Range("D5").Value = CachVers.Text End If End Sub Thanking you in advance. "Howard31" wrote: Hi zak, Let me put in steps what you should do. I hope this will help 1. Put a Button control on the Userform 2. Name the Button BtnSaveInfo 3 Change the Caption of the button to something descriptive maybe 'Save' or 'Save Info' 4. Double click the button 5. enter the follwing code in step 6 between the follwing code lines Private Sub BtnSaveInfo_Click() End Sub 6. Code to enter behind the button Dim Sht As Worksheet If OptionButton1.Value = True Then Set Sht = ThisWorkbook.Worksheets("Laptop1") Else Set Sht = ThisWorkbook.Worksheets("Laptop2") End If Sht.Range("A1").Value = TextBox1.Text Hope this helps, -- A. Ch. Eirinberg "zak" wrote: Hi I have a form with 2 radio buttons; one for Laptop 1 and the other for Laptop 2. Also on the form are some text input fields which is generic to both laptop 1 and 2. My question is, based on the radio button selected, i'd like to copy the information entered into the text fields on the form to the respective worksheet (worksheet Laptop 1 or worksheet Laptop 2). I'm not sure how to say If radio button 1 is selected,then write the info to worksheet Laptop 1 or If radio button 2 is selected then write the info to worksheet Laptop 2. I look forward to any help. Thank you |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Radio Button
Hi
Thanks for the code you have provided. I have managed to get the radio buttons working. I just had one more question, which I didn't receive a reply for: How can i say to add any new entry to the next row everytime the info is entered onto the form? I have added my code as it currently is below. Thanking you in advance. Private Sub BtnSaveInfo_Click() Dim Sht As Worksheet If Laptop1.Value = True Then Set Sht = ThisWorkbook.Worksheets("Toshiba (00226)") Sht.Range("A5").Value = TextBox2.Text Sht.Range("B5").Value = RecDate.Text Sht.Range("C5").Value = RSVers.Text Sht.Range("D5").Value = CachVers.Text Sht.Range("E5").Value = ApacVers.Text Sht.Range("F5").Value = TomcVers.Text Sht.Range("G5").Value = JavVers.Text Sht.Range("H5").Value = TextBox1.Text End If If Laptop2.Value = True Then Set Sht = ThisWorkbook.Worksheets("Dell (B000234)") Sht.Range("A5").Value = TextBox2.Text Sht.Range("B5").Value = RecDate.Text Sht.Range("C5").Value = RSVers.Text Sht.Range("D5").Value = CachVers.Text Sht.Range("E5").Value = ApacVers.Text Sht.Range("F5").Value = TomcVers.Text Sht.Range("G5").Value = JavVers.Text Sht.Range("H5").Value = TextBox1.Text End If End Sub "JLGWhiz" wrote: Had a typo in the first one. Use this set of code. Private Sub OptionButton1_Click() If Me.OptionButton1 = True Then Sheets("Laptop 1").Activate End If End Sub Private Sub OptionButton2_Click() If Me.OptionButton2 = True Then Sheets("Laptop 2").Activate End If End Sub "zak" wrote: Hi I have a form with 2 radio buttons; one for Laptop 1 and the other for Laptop 2. Also on the form are some text input fields which is generic to both laptop 1 and 2. My question is, based on the radio button selected, i'd like to copy the information entered into the text fields on the form to the respective worksheet (worksheet Laptop 1 or worksheet Laptop 2). I'm not sure how to say If radio button 1 is selected,then write the info to worksheet Laptop 1 or If radio button 2 is selected then write the info to worksheet Laptop 2. I look forward to any help. Thank you |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
radio button help | Excel Worksheet Functions | |||
"RADIO BUTTON" | Excel Discussion (Misc queries) | |||
How do I lock a radio button group if a N/A button is selected | Excel Discussion (Misc queries) | |||
VBA: Disable Frame and Radio Buttons based on Another Radio Button Being True | Excel Worksheet Functions | |||
Radio Button | Excel Programming |