VBA Textbox entry

hailstorm

New Member
Joined
Sep 14, 2019
Messages
34
Hello there,

I have this code that is filling my sheet3 with VLOOKUP formula. That's great. But i'd like to to put a number value before that ( Like a quantity number ).
Right now the code fills with data from Column C to Column H, i'd like to create a textbox in my userform to register the number value ( 1 to 99, for example ) in Column B without the need of VLOOKUP, pure and simple a quantity number in a textbox.

VBA Code:
Private Sub cmdSend_Click()
'Dim the variables
Dim cNum As Integer
Dim X As Integer
Dim nextrow As Range

'change the number for the number of controls on the userform
cNum = 6
Set nextrow = Sheet3.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0)
For X = 1 To cNum
nextrow = Me.Controls("Reg" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Cells(nextrow, 2) = reg7.Value
Next
MsgBox "The data has been sent"
'Clear the controls
cNum = 6
For X = 1 To cNum
Me.Controls("Reg" & X).Value = ""
Set nextrow = nextrow.Offset(0, 1)
Next
End Sub

 

Private Sub Reg1_AfterUpdate()
'Check to see if value exists
If WorksheetFunction.CountIf(Sheet2.Range("B:B"), Me.reg1.Value) = 0 Then
MsgBox "This is an incorrect ID"
Me.reg1.Value = ""
Exit Sub
End If
'Lookup values based on first control
With Me
.reg2 = Application.WorksheetFunction.VLookup(CLng(Me.reg1), Sheet2.Range("Lookup"), 2, 0)
.reg3 = Application.WorksheetFunction.VLookup(CLng(Me.reg1), Sheet2.Range("Lookup"), 3, 0)
.reg4 = Application.WorksheetFunction.VLookup(CLng(Me.reg1), Sheet2.Range("Lookup"), 4, 0)
.reg5 = Application.WorksheetFunction.VLookup(CLng(Me.reg1), Sheet2.Range("Lookup"), 5, 0)
.reg6 = Application.WorksheetFunction.VLookup(CLng(Me.reg1), Sheet2.Range("Lookup"), 6, 0)
End With
End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,215,360
Messages
6,124,493
Members
449,166
Latest member
hokjock

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top