Hello there. Forgive me as i am new to forums. I have been trying to find a way to fix my Excel 2010 userform for 3 days now and am getting desperate! I am creating an order number system, that is accessed from one document; New Order Number System.xlsm. I have created the userfrom, got all the vlookups working etc, but the only thing i cannot do is make it save to the next free row in: Order Number Record.xlsm (Which is stored on a network drive). I have written code to open the record, save to the first line, then save and close the form:
However as the code shows, it will overwrite every time the save button is pressed. I worked out how to find the next free cell in the active worksheet (New Order Number System.xlsm) with this code:
However i can not translate this code to work with the separate Excel file. I am not looking for someone to do the work, just to point me in the right direction please! I am very new to all this programming!!
Thank you in advance!
Code:
'Write record to first line of order number record
Dim nwb As Workbook
Set nwb = Workbooks.Open("M:\Jo Bond\EXPENDITURE\Order Number Record.xlsm")
With nwb.Sheets(1)
.Range("I2").Value = VerbalForm.TextBox7.Text
.Range("K2").Value = VerbalForm.PropertyBox.Text
.Range("M2").Value = VerbalForm.TextBox2.Text
.Range("B2").Value = VerbalForm.ContractorBox.Text
.Range("J2").Value = VerbalForm.TextBox6.Text
.Range("L2").Value = VerbalForm.TextBox1.Text
.Range("S2").Value = VerbalForm.ComboBox1.Text
.Range("T2").Value = VerbalForm.TextBox4.Text
.Range("U2").Value = VerbalForm.Label6.Caption
End With
'Close order number record
nwb.Close True
However as the code shows, it will overwrite every time the save button is pressed. I worked out how to find the next free cell in the active worksheet (New Order Number System.xlsm) with this code:
Code:
'Write chorus code to next free cell in current worksheet order numbers
Dim lRow As Long
Dim ws As Worksheet
Set ws = Sheet6
lRow = ws.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Row
'Add data to worksheet
ws.Cells(lRow, "B") = Me.TextBox7.Value
However i can not translate this code to work with the separate Excel file. I am not looking for someone to do the work, just to point me in the right direction please! I am very new to all this programming!!
Thank you in advance!