Re: Help With UserForm to enter Orders
.
Code:
'Col A = 1; Col B = 2; Col C = 3; Col D = 4; Col E = 5; Col F = 6; Col g = 7, etc. etc.
ws.Cells(newRow, 1).Value = Me.txtFirstName.Text
ws.Cells(newRow, 2).Value = Me.txtSurname.Text
ws.Cells(newRow, 1) ... the number One after "newRow" is equal to the column A.
ws.Cells(newRow, 2) ... the number Two after "newRow" is equal to the column B.
Refer to the commented line at top ... you can see where 1 = Col A; 2 = Col B; 3 = Col C, etc. etc.
This : ws.Cells(newRow, 1) translates to :
ws (defined at the top of the macro as the ActiveSheet)
Cells(newRow, 1) translates to the newRow, Col A.
The "newRow", using the macro provided, will always be the first blank row after the last used row in Col A. That is defined with this line :
newRow = Application.WorksheetFunction.CountA(ws.Range("A:A")) + 1
newRow generates the data to populate to the new row ... first blank row below the last used row.
Referring to this portion :
ws.Cells(newRow, 1).Value = Me.txtFirstName.Text
The text entered into the UserForm textbox named txtFirstName, will be populated to the first blank cell in Col A.
ws.Cells(newRow, 2).Value = Me.txtSurname.Text
The text entered into the UserForm textbox named txtSurname will be populated to the first blank cell in Col B.
Edit the UserForm to fit your needs for your ordering system. Add more textboxes to accommodate all the different fields you laid out in your original post.
For example :
Customer Name .... you could name a UserForm textbox as txtCustName
SO# ... you could name a UserForm textbox as txtSONum
LINE # ... you could name a UserForm textbox as txtLineNum
PART# ... you could name a UserForm textbox as txtPartNum
PRICE ... you could name a UserForm textbox as txtPrice
You have five fields, so you will need five text boxes.
Customer Name = Col A
So # = Col B
Line # = Col C
Part # = Col D
Price # = Col E