Link to home
Start Free TrialLog in
Avatar of jmacalpine
jmacalpine

asked on

VBA Error

I have a VBA script to run.. Get an error 5 When I try to run..Upon debugging, I am told that the Line (I've underlined it) below is using the wrong argument... I've tried a few different ways to declare that worksheet as the one I need but to no avail.

Thoughts?


Sub Tally()
Dim subj As String
subj = Worksheets("Bol Breakdown").Range("R1").Value
company = Worksheets("New").Range("N1").Value
filesformat = "PDF\Tally Sheets"
livescrap = Worksheets("New").Range("N3").Value
yeardate = Worksheets("New").Range("N4").Value
monthdate = Worksheets("New").Range("N5").Value
pathtosaveto = "S:\ARC\" & company & "\" & filesformat & "\" & yeardate & "\" & monthdate & "\" & subj

Worksheets("BOL Breakdown").ExportAsFixedFormat Type:=xlTypePDF, Filename:=pathtosaveto, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Well I don't know what is in your "pathtosaveto" but otherwise your code works for me. If the sheet name were incorrect you'd get a Subscript out of range error.
Avatar of jmacalpine
jmacalpine

ASKER

pathtosaveto = "S:\ARC\" & company & "\" & filesformat & "\" & yeardate & "\" & monthdate & "\" & subj
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial