Insert value in text box based on previous tselected value.

M

Mike K

Oh Wise Ones,

The first block on this user forms allows me to select the product based on
1 of 3 radio button selections.

Sub EnterData_Click()
Worksheets("Open Red Tags").Activate
Worksheets("Open Red Tags").Rows(4).Insert
If TL30.Value = True Then
Worksheets("Data").Range("A2").Copy
ActiveSheet.Paste Destination:=Worksheets("Red Tag").Range("D6,D32")
Worksheets("Data").Range("C2").Copy
ActiveSheet.Paste Destination:=Worksheets("Open Red Tags").Range("D4")
End If
If TL40.Value = True Then
Worksheets("Data").Range("A3").Copy
ActiveSheet.Paste Destination:=Worksheets("Red Tag").Range("D6,D32")
Worksheets("Data").Range("C3").Copy
ActiveSheet.Paste Destination:=Worksheets("Open Red Tags").Range("D4")
End If
If TLLT.Value = True Then
Worksheets("Data").Range("A4").Copy
ActiveSheet.Paste Destination:=Worksheets("Red Tag").Range("D6,D32")
Worksheets("Data").Range("C4").Copy
ActiveSheet.Paste Destination:=Worksheets("Open Red Tags").Range("D4")

Then it calls a text box that always displays a Default value of 12. It
would be nice to have the "12" replaced by either 12 if TL30 is selected, 9
if TL40 is selected, or 6 if TLLT is selected.

Dim Message, Title, Default, Squares
Dim TagNumber As Integer

Message = "Enter the number of squares for this tag" ' Set prompt.
Title = "Squares" ' Set title.
Default = "12" ' Set default.
' Display message, title, and default value.
Squares = InputBox(Message, Title, Default)

How can I replace the 12 with the selected product reference number?

Thanks,
Mike
 
D

DanRoss

'Im making some assumptions based on what I see but . . . . (example is not
checked for correctness it's just a basic sample) . .. it looks like you
could . . .

Dim Message, Title, Default, Squares
Dim TagNumber As Integer
Message = "Enter the number of squares for this tag" ' Set prompt.
Title = "Squares" ' Set title.

'ADD THIS to SET Default
IF TL30.Value = True Then
Default = "12"
ElseIF TL40.Value = True Then
Default = "9"
ElseIF TLLT.Value = True Then
Default = "6"
Else 'Unknow value so assume 12
Default = "12"
End if

' Display message, title, and default value.
Squares = InputBox(Message, Title, Default)
 
M

Mike K

Aaaahh, I will give that a try.

Thanks Dan!


DanRoss said:
'Im making some assumptions based on what I see but . . . . (example is not
checked for correctness it's just a basic sample) . .. it looks like you
could . . .

Dim Message, Title, Default, Squares
Dim TagNumber As Integer
Message = "Enter the number of squares for this tag" ' Set prompt.
Title = "Squares" ' Set title.

'ADD THIS to SET Default
IF TL30.Value = True Then
Default = "12"
ElseIF TL40.Value = True Then
Default = "9"
ElseIF TLLT.Value = True Then
Default = "6"
Else 'Unknow value so assume 12
Default = "12"
End if

' Display message, title, and default value.
Squares = InputBox(Message, Title, Default)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top