Pulling next number in line based on last entry from a different workbook into a userform

JeremyA1976

Board Regular
Joined
Aug 3, 2015
Messages
59
I am trying to link two workbooks together. I have a main form and I have a log. I have already created the log with sequential numbering starting at 120000. This will be my charge out number. On my main form template, the user's first responsibility is to fill out the userform information (Date, job number, customer, author & charge out number). Once the text fields are filled out and submitted, they populate my main form basic information on sheet1.
Date = Cell M1
CO# = Cell O1
Job No. = Cell M2
Customer = Cell M3
Author = Cell M4

The user then fills out all the charge out materials which results in a list of pertinent information on my main form. What i would like to see happen is for the userform "ChargeOutInfo" to automatically look in the workbook "Charge Out Log.xlsm", find the last entry in column B, go one row down and retrieve the Charge out number in column A. I currently have a textbox in the userform to manually input a number, but it should be replaced with the retrieved number from the log, so that the user can NOT change this number. Here is the code I have for my ChargeOutInfo for the submit button:

Private Sub ChargeOutInfo_Initialize()


End Sub


Private Sub Image2_Click()


Dim ws1 As Worksheet

Set ws1 = Worksheets("CHARGE OUT FORM")

'Charge Out Form
ws1.Range("M1") = Date
ws1.Range("O1") = TextBox1.Value
ws1.Range("M2") = TextBox2.Value
ws1.Range("M3") = TextBox3.Value
ws1.Range("M4") = TextBox4.Value
ws1.Range("N5") = TransferfromJobNo.Value

Dim i As Long
Dim ans As String
Dim Ms As String
Dim Mss As String
Mss = "ALL Textboxes must be filled in!"
Ms = "These TextBoxs are empty"
For i = 4 To 1 Step -1
If Controls("TextBox" & i).Value = "" Then ans = Controls("Textbox" & i).Name & vbNewLine & ans
Next
If ans <> "" Then
MsgBox Ms & vbNewLine & ans & vbNewLine & Mss
Else
MsgBox "All Information is Added. Thank You!"
End If

End

End Sub


I would like for the retrieved charge out number to show up on the userform, but its not a necessity at this point. As long as each charge out submission has a different number for tracking, then i can deal with everything else. Can someone please help shed some light on this for me? Thanks
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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