Results 1 to 19 of 19

Macro doesn't work when filename changes!

Threaded View

  1. #1
    Registered User
    Join Date
    07-05-2010
    Location
    Calgary, AB, Canada
    MS-Off Ver
    Excel 2007
    Posts
    11

    Talking Macro doesn't work when filename changes!

    Good day everyone!
    I hope someone can help me out...

    I am currently trying to run a macro on a spreadsheet to consolidate information.
    It works fine on the original file...
    This file will become a template of sorts which will allow other users to run the macro to expedite the workload.... So each individual who saves the template wherever they want can still run this macro.

    When I change the directory or filename the 1004 error appears... as it cannot locate the original file...
    The macro looks like this:
    
    Sub ConsolidateIVR()
    '
    ' ConsolidateIVR Macro
    ' Consolidates IVR
    '
    ' Keyboard Shortcut: Ctrl+Shift+V
    '
        Selection.Consolidate Sources:= _
            "'C:\Users\office2\Cristina''s Folder\IVR Project\[TRIAL 1.xls]IVR Info'!R1C1:R92C8" _
            , Function:=xlSum, TopRow:=True, LeftColumn:=True, CreateLinks:=False
        Range("C2").Select
        ActiveCell.FormulaR1C1 = "=V"
        Range("C2").Select
        ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-2],'IVR Info'!RC[-2]:R[93]C,3,FALSE)"
        Range("C2").Select
        Selection.AutoFill Destination:=Range("C2:C92")
        Range("C2:C92").Select
    End Sub
    Is there a way I can change the path to "This workbook"??? I'm not sure what the programming should be...
    I'm self taught at excel... and vbasic is waaaay beyond my expertise...
    I actually just taught myself macros and consolidation last week....

    I'm not sure if I'm explaining myself clearly or not....

    I want the macro to run if the file is elsewhere or named something else....

    Thanks for your help!!
    Last edited by CristinaS; 07-05-2010 at 04:29 PM. Reason: add code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1