LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Anthony
 
Posts: n/a
Default Macro script error - pls help !!

Hi,
A button on worksheet1 (mondays log) is selected by the user and he/she is
then asked which job they wish to print - on input that number is searched
for in column B of Monday's log and the contents of that row are copied and
pasted into row A2 of sheet2 (Formula).
The script I have been given below works almost perfectly apart from the
following errors.

in 'monday's log' row B8 has job number 1, row B9 has job number 23 and the
rest of the rows are blank (for the moment)

The user inputs job 1 to print outcome is perfect
The user inputs job 2 to print and job 23 is picked up and printed
The user inputs job 3 to print and job 23 is picked up and printed
The user inputs job 4 to print and 'zero' values are picked up and printed
any other number entered by the user works fine (ie the error is shown if no
job with the input number is found).

I don't understand why when job 2 is selected number 23 is selected and the
same for job 3, or why if job 4 is selected I get a page of 'zero' values

Can anybody solve this for me

here is the script I was given

Sub print_mon_jobcard()

Dim i As Integer
Dim iRow As Integer
Dim wks1 As Worksheet, wks2 As Worksheet, wks3 As Worksheet
Dim lLastRow As Long
On Error GoTo err_handler
Set wks1 = Worksheets("monday's log")
Set wks2 = Worksheets("formula")
Set wks3 = Worksheets("jobcard")
i = InputBox("Please enter the job number you wish to print a job card for")
iRow = Columns("B:B").Find _
(What:=i, _
After:=Range("B1"), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Row
Worksheets("monday's log").Activate
ActiveSheet.Cells(iRow, 1).EntireRow.Copy Destination _
:=Worksheets("formula").Cells(2, 1)

wks3.PrintOut preview:=True
Exit Sub

err_handler:
MsgBox "No job with the number " & i & " has been found, please try
again!"
End Sub

Many many thanks for any help

Anthony
 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM
Macro Formula revision? Mark Excel Worksheet Functions 1 November 28th 04 01:43 AM
Macro for multiple charts JS Excel Worksheet Functions 1 November 19th 04 03:44 AM


All times are GMT +1. The time now is 02:47 PM.

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"