rmc71291
asked on
Store Value from one form and then ask for a multiplier in second form
Again, I am horrible in Excel VBA so please take it easy on me.
What I am trying to do is store a numerical value of a barcode in UserForm7.Textbox1 using the first set of code then have the application wait 2 seconds and then open UserForm8 and store an integer that is hand-typed in Userform8.Texbox1. Then on button click it looks up the barcode value in the sheet, shifts one cell to the right, and adds the muliple from UserForm8.TextBox1 to the number that already exists in that cell. Running into all kinds of issues but the first was I had UserForm7 and UserForm8 showing up at the same time.
I can certainly add more code or upload the file if it helps you help me.
What I am trying to do is store a numerical value of a barcode in UserForm7.Textbox1 using the first set of code then have the application wait 2 seconds and then open UserForm8 and store an integer that is hand-typed in Userform8.Texbox1. Then on button click it looks up the barcode value in the sheet, shifts one cell to the right, and adds the muliple from UserForm8.TextBox1 to the number that already exists in that cell. Running into all kinds of issues but the first was I had UserForm7 and UserForm8 showing up at the same time.
I can certainly add more code or upload the file if it helps you help me.
Private Sub TextBox1_Change()
If Not IsActive And TextBox1.Text <> "" Then
IsActive = True
Application.OnTime Now + TimeValue("00:00:03"), "UserForm7.Hide"
UserForm8.Show
End If
End Sub
Private Sub UserForm_Initialize()
IsActive = False
TextBox1.SetFocus
End Sub
Private Sub btn_MultipleAdd_Click()
Worksheets("Main").Unprotect
Dim TargetCell As Range
Dim TextBox1 As Integer
If WorksheetFunction.CountIf(Sheets("Main").Columns(4), TextBox1.Value) = 1 Then
Set TargetCell = Sheets("Main").Columns(4).Find(TextBox1.Value, , xlValues, xlWhole).Offset(0, 1)
TargetCell.Value = TargetCell.Value + TextBox1
TextBox1.Value = ""
TextBox1.SetFocus
Else
MsgBox "Item Not Found"
End If
Worksheets("Main").Protect
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Other responses did not quite answer as asked but offered reasonable alternatives. In the end, I chose a different route than the original question or the alternate solutions.
if not then you need to declare a Global variable that will store the bar code