Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
Hi,
I'm quite new to this kinda thing so go easy! Ok, I have a workbook with 3 worksheets 1) Customer Name , ie John Smith 2) A selection of data copy/pasted from 'John Smith's' oder form into Invoice data (this data is an entire row - which is row 35 or cells A35:AB35) 3) Invoice master form. What I have is a macro button on my personal tool bar which I want the user to be able to select anywhere in the workbook. A msg box comes up asking to input name of customer who's invoice is to printed. That order form is seached for , the data collected, pasted into the 'Invoice Data' worksheet, then the actual invoice printed. However the code I have isn't quite correct - I have tried to adapt it from another similar one I have but I can't get this one to work. Here's what I am using............... Sub print_Invoice() Dim i As Integer Dim sSheetName As String Dim iRow As Integer Dim Cel As Range Dim wks1 As Worksheet, wks2 As Worksheet, wks3 As Worksheet Dim lLastRow As Long 'On Error GoTo err_handler Set wks1 = ThisWorkbook.Worksheets(sSheetName) Set wks2 = ThisWorkbook.Worksheets("Invoive data") Set wks3 = ThisWorkbook.Worksheets("Invoice") sSheetName = InputBox("Please enter the Name of the Customer who's invoice is to be printed, ie John Smith") If sSheetName = 0 Then Exit Sub On Error Resume Next Set Cel = wks1.Columns("A:A").Find _ (What:=i, _ LookIn:=xlValues, _ LookAt:=xlWhole) If Cel Is Nothing Then MsgBox "No Order found with the name of " & i & " , please try again! " Exit Sub End If On Error GoTo err_handler wks1.Cells("A35:AC35").EntireRow.Copy Destination _ :=wks2.Cells(2, 1) wks3.PrintOut Exit Sub err_handler: MsgBox Error, , "Err " & Err.Number End Sub Can anybody offer me a solution ??? many many many thanks |