Same question - Label not defined in Error Handling.

On Error GoTo AltSave

AltSave:
MyDocsPath = "F:\Users\" & LoginID & "\My Documents"
ActiveWorkbook.SaveAs Filename:= _
        MyDocsPath & "\Consumption Upload " & MyMarket & ".txt" _
        , FileFormat:=xlText, CreateBackup:=False
Resume Next
JodiSongAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Is that the complete code?

How about this?

On Error GoTo AltSave

Exit Sub ' or Function
AltSave:
MyDocsPath = "F:\Users\" & LoginID & "\My Documents"
ActiveWorkbook.SaveAs Filename:= _
        MyDocsPath & "\Consumption Upload " & MyMarket & ".txt" _
        , FileFormat:=xlText, CreateBackup:=False
Resume Next
JodiSongAuthor Commented:
No.  Complete code:

Sub Upload_Consumption()
'
' Upload_Consumption Macro
'
Dim LastRow As Integer

Dim LoginID As String
Dim MyMarket As String
Dim MyDocsPath As String

    LoginID = Environ("UserName")
    MyDocsPath = Environ$("USERPROFILE") & "\My Documents"

    Sheets("Upload Changes").Select
    Range("A1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.ClearContents
    Sheets("Adjustments").Select
   
    ActiveSheet.Range("$A$1:$P$7000").AutoFilter Field:=15, Criteria1:="<>"
    Range("A1").Select
    ActiveCell.End(xlDown).Select
    LastRow = ActiveCell.Row
    Range("C1:C" & LastRow).Select
       
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    Sheets("Upload Changes").Select
    Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("A1").Select
    Application.CutCopyMode = False
    Sheets("Adjustments").Select
    Range("E1:E" & LastRow).Select
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    Sheets("Upload Changes").Select
    Range("B1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("Adjustments").Select
    Range("H1:H" & LastRow).Select
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    Sheets("Upload Changes").Select
    Range("C1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("Adjustments").Select
    Range("P1:P" & LastRow).Select
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    Sheets("Upload Changes").Select
    Range("D1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

    Range("P1").Select
    ActiveCell.FormulaR1C1 = "1"
    Selection.Copy
    Range("B2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
        SkipBlanks:=False, Transpose:=False
    Range("P1").Select
    Application.CutCopyMode = False
    Selection.ClearContents
     
    Sheets("Adjustments").Select
       
    ActiveSheet.Range("$A$1:$P$7000").AutoFilter Field:=15
    Sheets("Upload Changes").Select
    Range("C2").Select
    MyMarket = ActiveCell.Value
    Sheets("Upload Changes").Copy
    Application.DisplayAlerts = False
   
    On Error GoTo AltSave
   
    ActiveWorkbook.SaveAs Filename:= _
        MyDocsPath & "\Consumption Upload " & MyMarket & ".txt" _
        , FileFormat:=xlText, CreateBackup:=False
                 
    Application.Dialogs(xlDialogSendMail).Show
    ActiveWindow.Close
    Application.DisplayAlerts = True
   
    MsgBox "Complete"
   
End Sub

AltSave:
MyDocsPath = "F:\Users\" & LoginID & "\My Documents"
ActiveWorkbook.SaveAs Filename:= _
        MyDocsPath & "\Consumption Upload " & MyMarket & ".txt" _
        , FileFormat:=xlText, CreateBackup:=False
Resume Next
GrahamSkanRetiredCommented:
Make sure that the labelled error handler is later in the procedure than code that might raise any run-time errors.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
I would expect the error handle to be located in the same scope, i.e, the sub, it is used in.
Rgonzo1971Commented:
Hi,

pls try

Sub Upload_Consumption()
 '
 ' Upload_Consumption Macro
 '
 Dim LastRow As Integer

 Dim LoginID As String
 Dim MyMarket As String
 Dim MyDocsPath As String

     LoginID = Environ("UserName")
     MyDocsPath = Environ$("USERPROFILE") & "\My Documents"

     Sheets("Upload Changes").Select
     Range("A1").Select
     Range(Selection, Selection.End(xlDown)).Select
     Range(Selection, Selection.End(xlToRight)).Select
     Selection.ClearContents
     Sheets("Adjustments").Select
     
     ActiveSheet.Range("$A$1:$P$7000").AutoFilter Field:=15, Criteria1:="<>"
     Range("A1").Select
     ActiveCell.End(xlDown).Select
     LastRow = ActiveCell.Row
     Range("C1:C" & LastRow).Select
        
     Selection.SpecialCells(xlCellTypeVisible).Select
     Selection.Copy
     Sheets("Upload Changes").Select
     Range("A1").Select
     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
         :=False, Transpose:=False
     Range("A1").Select
     Application.CutCopyMode = False
     Sheets("Adjustments").Select
     Range("E1:E" & LastRow).Select
     Selection.SpecialCells(xlCellTypeVisible).Select
     Selection.Copy
     Sheets("Upload Changes").Select
     Range("B1").Select
     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
         :=False, Transpose:=False
     Sheets("Adjustments").Select
     Range("H1:H" & LastRow).Select
     Selection.SpecialCells(xlCellTypeVisible).Select
     Selection.Copy
     Sheets("Upload Changes").Select
     Range("C1").Select
     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
         :=False, Transpose:=False
     Sheets("Adjustments").Select
     Range("P1:P" & LastRow).Select
     Selection.SpecialCells(xlCellTypeVisible).Select
     Selection.Copy
     Sheets("Upload Changes").Select
     Range("D1").Select
     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
         :=False, Transpose:=False

     Range("P1").Select
     ActiveCell.FormulaR1C1 = "1"
     Selection.Copy
     Range("B2").Select
     Range(Selection, Selection.End(xlDown)).Select
     Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
         SkipBlanks:=False, Transpose:=False
     Range("P1").Select
     Application.CutCopyMode = False
     Selection.ClearContents
      
     Sheets("Adjustments").Select
        
     ActiveSheet.Range("$A$1:$P$7000").AutoFilter Field:=15
     Sheets("Upload Changes").Select
     Range("C2").Select
     MyMarket = ActiveCell.Value
     Sheets("Upload Changes").Copy
     Application.DisplayAlerts = False
     
     On Error GoTo AltSave
     
     ActiveWorkbook.SaveAs Filename:= _
         MyDocsPath & "\Consumption Upload " & MyMarket & ".txt" _
         , FileFormat:=xlText, CreateBackup:=False
                  
     Application.Dialogs(xlDialogSendMail).Show
     ActiveWindow.Close
     Application.DisplayAlerts = True
     
     MsgBox "Complete"
     
Exit Sub

 AltSave:
 MyDocsPath = "F:\Users\" & LoginID & "\My Documents"
 ActiveWorkbook.SaveAs Filename:= _
         MyDocsPath & "\Consumption Upload " & MyMarket & ".txt" _
         , FileFormat:=xlText, CreateBackup:=False
 Resume Next 
End Sub

Open in new window

Regards
JodiSongAuthor Commented:
No matter where I put the code, I still get the error.  Some of my users have their My Documents drive on C, others have theirs on a network drive.  I'm trying to make a fix for those few that are on the network.
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Did you try Rgonzo's code, too? It is exactly what I was talking about.
JodiSongAuthor Commented:
I've moved things around, put on & taken off colons, added Exit Subs.  Nothing works.
Martin LissOlder than dirtCommented:
The problem with your code was that the AltSave error routine was outside of the sub where you were trying to use it. In other words it followed the End Sub.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JodiSongAuthor Commented:
Thanks, I'll move it and send it to one of my network users to see if it fixes his problem.
Martin LissOlder than dirtCommented:
If that does fix it then you should give at least half the points to Rgonzo1971.
JodiSongAuthor Commented:
If you'll tell me how to do that, then I will.
Martin LissOlder than dirtCommented:
Please see this EE article.
JodiSongAuthor Commented:
Even if no error was encountered, the code still wanted to run the error handler.  I had to create a separate macro for those exclusively with their My Documents folder on the server.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.