hello
I need adding currency to textbox when populate values in textbox based on name optionbutton name
optionbutton1 is DL and optionbutton2 RMT name so when populate the values in textbox should like this
I need adding currency to textbox when populate values in textbox based on name optionbutton name
optionbutton1 is DL and optionbutton2 RMT name so when populate the values in textbox should like this
VBA Code:
Option Explicit
Private Sub UserForm_Initialize()
Me.ComboBox1.RowSource = ""
With Sheets("sh1").Cells(1).CurrentRegion
Me.ComboBox1.List = .Columns("b:e").Offset(1).Resize(.Rows.Count - 1).Value
End With
End Sub
Private Sub OptionButton1_Click()
If Me.OptionButton1 Then
If Me.ComboBox1.ListIndex > -1 Then ComboBox1_Change
End If
End Sub
Private Sub OptionButton2_Click()
If Me.OptionButton2 Then
If Me.ComboBox1.ListIndex > -1 Then ComboBox1_Change
End If
End Sub
Private Sub ComboBox1_Change()
Dim i As Long
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
If (Not Me.OptionButton1) * (Not Me.OptionButton2) Then
MsgBox "Select Option first", vbCritical: Exit Sub
End If
With Me.ComboBox1
For i = 0 To 2
Me("textbox" & i + 1) = Format$(.List(.ListIndex, i), "#,##0.00;;@")
If (i = 2) * (Me.OptionButton2) Then
Me("textbox" & i + 1) = Format$(.List(.ListIndex, i + 1), "#,##0.00")
End If
Next
Me.TextBox4 = Format$(Val(.List(.ListIndex, 1)) * Val(.List(.ListIndex, 2 + IIf(Me.OptionButton1, 0, 1))), "#,##0.00")
End With
End Sub