ThrottleWorks
Excel Ninja
Hi,
I am using below mentioned code to populate Textboxes through Userform.
For example if the value in cell B1 is 1, UF will show 1 Textbox, if the value is 3 UF will show 3 T.B. and so on.
My problem is, the value in cell B1 keeps changing. For example,
When I 1st run the macro, B1 value was 3, when I run the macro for second time, value in B1 is 1 but the macro will still show 3 Textboxes instead on 1.
And, this is not consistent also, suppose UF shows 3 T.B. and I know it should show 2 T.B then I close the userform manually and re-try.
On the re-try macro will show correct number for Textboxes.
Sorry for not uploading the file. Can anyone please help me in this.
I am using below mentioned code to populate Textboxes through Userform.
For example if the value in cell B1 is 1, UF will show 1 Textbox, if the value is 3 UF will show 3 T.B. and so on.
My problem is, the value in cell B1 keeps changing. For example,
When I 1st run the macro, B1 value was 3, when I run the macro for second time, value in B1 is 1 but the macro will still show 3 Textboxes instead on 1.
And, this is not consistent also, suppose UF shows 3 T.B. and I know it should show 2 T.B then I close the userform manually and re-try.
On the re-try macro will show correct number for Textboxes.
Sorry for not uploading the file. Can anyone please help me in this.
Code:
BoxCnt = ThisWorkbook.Worksheets("Macro").Range("b1").Value
Code:
Private Sub UserForm_Initialize()
If BoxCnt = 3 Then
TextBox1.Value = ThisWorkbook.Worksheets("Macro").Range("a1").Value
TextBox2.Value = ThisWorkbook.Worksheets("Macro").Range("a2").Value
TextBox3.Value = ThisWorkbook.Worksheets("Macro").Range("a3").Value
End If
If BoxCnt = 2 Then
TextBox1.Value = ThisWorkbook.Worksheets("Macro").Range("a1").Value
TextBox2.Value = ThisWorkbook.Worksheets("Macro").Range("a2").Value
TextBox3.Visible = False: cmd3.Visible = False
End If
If BoxCnt = 1 Then
TextBox1.Value = ThisWorkbook.Worksheets("Macro").Range("a1").Value
TextBox2.Visible = False: TextBox3.Visible = False
cmd2.Visible = False: cmd3.Visible = False
End If
End Sub
Last edited: