Userform Input data to Next blank Row when each entry

hajiali

Active Member
Joined
Sep 8, 2018
Messages
304
Office Version
  1. 2016
Platform
  1. Windows
1597168415458.png

were Textbox1 = Employee Number
and Textbox2 = Line Chooses

VBA Code:
Private Sub CommandButton1_Click()

Dim EmpID$, dDate$, Rg As Range, i&, x&
EmpID = TextBox1.Value
If TextBox1.Value = "" Or TextBox2.Value = "" Then
   MsgBox "PLEASE FILL IN EMPLOYEE NUMBER & ENTER BID LINE CHOOSES ... ", vbExclamation: Exit Sub
End If

If Not IsNumeric(EmpID) Then MsgBox "INVALID EMPLOYEE NUMBER ENTER NUMBER WITHOUT THE E", vbExclamation: Exit Sub

With Sheets("SHIFT BIDS")
   For i = 1 To 2
      dDate = IIf(i = 1, TextBox1.Value, TextBox2.Value)
      If Len(dDate) > 0 Then
         Set Rg = .Columns(1).Find(EmpID, lookat:=xlWhole)
         If Rg Is Nothing Then
            MsgBox "EMPLOYEE NUMBER DOES NOT EXIST PLEASE TRY AGAIN", vbExclamation: Exit Sub
         Else
            Set Rg = IIf(i = 1, ThisWorkbook.Sheets("Bid Data").Cells(, "D").Resize(500), ThisWorkbook.Sheets("Bid Data").Cells(, "E").Resize(, 500))
            If InStr(dDate, ".") Then
               For x = 0 To UBound(Split(dDate, "."))
               Next
               For x = 0 To UBound(Split(dDate, "."))
                  Rg.Find("", after:=Rg.Cells(Rg.Count)) = Split(dDate, ".")(x)
               Next
            Else
               Rg.Find("", after:=Rg.Cells(Rg.Count)) = dDate
            End If
         End If
      End If
   Next
End With
TextBox1.Value = ""
TextBox2.Value = ""
TextBox1.SetFocus
End Sub
when I type in 9324 in Textbox1 and 1.2.3 and textbox2 and press enter on the first set of data then type 6475 textbox1 and 10.9.8 in textbox2 and press enter for the second set of data The results I get with the above code is as follows:
DEFGHIJ
9324​
1​
2​
3​
10​
9​
8​
6475​

What I need done is the second data of textbox2 to go with second data of textbox1 so results should be:
DEFGHIJ
9324​
1​
2​
3​
6475​
10​
9​
8​


any help is greatly appreciated.
 

Some videos you may like

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
48,023
Office Version
  1. 365
Platform
  1. Windows
@hajiali
While we do allow Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 

Watch MrExcel Video

Forum statistics

Threads
1,113,824
Messages
5,544,539
Members
410,619
Latest member
gregor222
Top