Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Zak Zak is offline
external usenet poster
 
Posts: 144
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default 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   Report Post  
Posted to microsoft.public.excel.programming
Zak Zak is offline
external usenet poster
 
Posts: 144
Default 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   Report Post  
Posted to microsoft.public.excel.programming
Zak Zak is offline
external usenet poster
 
Posts: 144
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
radio button help tjb Excel Worksheet Functions 1 September 27th 05 01:16 AM
"RADIO BUTTON" Ian Shere Excel Discussion (Misc queries) 1 July 4th 05 10:59 PM
How do I lock a radio button group if a N/A button is selected worry a lot Excel Discussion (Misc queries) 2 May 21st 05 08:33 PM
VBA: Disable Frame and Radio Buttons based on Another Radio Button Being True Mcasteel Excel Worksheet Functions 2 October 29th 04 07:06 PM
Radio Button Powlaz Excel Programming 1 August 5th 04 03:03 AM


All times are GMT +1. The time now is 11:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"