ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert value in text box based on previous tselected value. (https://www.excelbanter.com/excel-programming/405505-insert-value-text-box-based-previous-tselected-value.html)

Mike K

Insert value in text box based on previous tselected value.
 
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

DanRoss

Insert value in text box based on previous tselected value.
 
'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)



"Mike K" wrote in message
...
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



Mike K

Insert value in text box based on previous tselected value.
 
Aaaahh, I will give that a try.

Thanks Dan!


"DanRoss" wrote:

'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)



"Mike K" wrote in message
...
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




All times are GMT +1. The time now is 07:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com