LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Anthony
 
Posts: n/a
Default VB copde help - please!

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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"