Hello,
I am working on a project to make the sales staff's job easier. I have created a Quote form that we use for all our quoting. Now I am working on an invoice form where we can just pull the information from a quote into the invoice. The quotes are all saved in one folder with name format Qt-1, Qt-2....
I found a VBA code that pulls the information from the quote into the invoice. Works great, however I would like to use that code in a userform where the sales staff can enter the quote number and the magic happens with a click of a button. In the code I have the file path and the workbook I want to retrieve. The file path and name (TestInvoice) will always be the same, the only variable will be the document name. That variable number I would like to be entered in a textbox in the userform.
How can this code be modified to work in a userform?
Option Explicit
Sub RetrieveQoute()
Dim wb As Workbook
Application.ScreenUpdating = False
Set wb = Workbooks.Open("C:\Users\Username\Desktop\TestInvoice\Qt-1.xlsx", True, True)
With ThisWorkbook.Worksheets(1)
.Range("B17:B25").Value = wb.Worksheets(1).Range("B17:B25").Value
.Range("C17:C25").Value = wb.Worksheets(1).Range("C17:C25").Value
.Range("D17:D25").Value = wb.Worksheets(1).Range("D17:D25").Value
.Range("B10:B14").Value = wb.Worksheets(1).Range("B10:B14").Value
.Range("F7").Value = wb.Worksheets(1).Range("F5").Value
.Range("F6").Value = wb.Worksheets(1).Range("F6").Value
End With
wb.Close False
Set wb = Nothing
Application.ScreenUpdating = True
End Sub
Display More