+ Reply to Thread
Results 1 to 11 of 11

Consolidate macro then I get #REF formula error when sharing workbook

Hybrid View

  1. #1
    Registered User
    Join Date
    11-30-2009
    Location
    Mexico
    MS-Off Ver
    Excel 2003
    Posts
    29

    Lightbulb Consolidate macro then I get #REF formula error when sharing workbook

    Ok I have a macro that consolidates multiple worrksheets into one master.
    When I share (send by email) this master, my colleagues can't see the information that have formulas, the only got the #REF error and if they look at the formula the have something like this "=VLOOKUP(N18,'C:\Users\JJI\AppData\Local\Temp\notesE69A9C\HC MARCH 1.xlsx'!Salary[[#All],[EmpID]:[Department]],79,0)"
    I think because the formula refers to my computer.
    I can not add to the Macro to copy a formula because some of the cells in the same column have formulas and some text

    How can I fix it?


    Appreciate your help!!!
    Last edited by jjislas; 03-22-2012 at 12:04 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-14-2012
    Location
    Arizona USA
    MS-Off Ver
    Excel 2000/2007
    Posts
    408

    Re: Consolidate macro then I get #REF formula error when sharing workbook

    Instead of saving the master as an excel file, save it as a CSV file.

  3. #3
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Consolidate macro then I get #REF formula error when sharing workbook

    you you could paste values of the spreadsheet and save that as a seperate 'shareable' file that you could send to your colleagues.
    If you liked my solution, please click on the Star -- to add to my reputation

    If your issue as been resolved, please clearly state so and mark the thread as [SOLVED] using the thread tools just above the first post.

  4. #4
    Registered User
    Join Date
    11-30-2009
    Location
    Mexico
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Consolidate macro then I get #REF formula error when sharing workbook

    saving as csv doesn't work because they need them in excel

    saving as values doesn't work either because they need to manipulate the file and use the formulas

    ** The formulas refer to another worksheet hide in the woorkbook, but when I consolidate and save the vlookup formula refers to the location of the file in my computer, the original formula refers to a table in a hidden sheet
    As I already mention I can not copy the formula down the column because some cells are text and not formulas

  5. #5
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Consolidate macro then I get #REF formula error when sharing workbook

    if that other worksheet is in the same book, try doing a find replace on your sheet to modify your formulas not to look outside the book. replace all instances of 'C:\Users\JJI\AppData\Local\Temp\notesE69A9C\HC MARCH 1.xlsx' with nothing.

  6. #6
    Registered User
    Join Date
    11-30-2009
    Location
    Mexico
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Consolidate macro then I get #REF formula error when sharing workbook

    DGagnon yes we are close, how can I make that in VB so I can integrate it in the macro when I consolidate my worrkbooks?

    Since the root will be changing everytime I consolidate it need to be with variables, can it be done?
    I already have one called root that gives me the root where the file is: C:\Users\JJI\AppData\Local\Temp\notesE69A9C\
    Also have other variable with the workbookname: HC MARCH 1.xlsx

    I did a macro record and got this code:

    Cells.Replace What:= _
    "'C:\Users\FZN5LB\Documents\Juanjo Data\HUM025 - Headcount\2012 03\Manpower Marzo\Manpower HC Ramos Marzo.xlsx'!Salary" _
    , Replacement:="Salary", LookAt:=xlPart, SearchOrder:=xlByRows, _
    MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False

  7. #7
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Consolidate macro then I get #REF formula error when sharing workbook

    try using this:

    Cells.Replace What:= _
    "'" & ActiveWorkbook.Path & "[" & ActiveWorkbook.Name & "]" _
    , Replacement:="'", LookAt:=xlPart, SearchOrder:=xlByRows, _
    MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False

  8. #8
    Registered User
    Join Date
    11-30-2009
    Location
    Mexico
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Consolidate macro then I get #REF formula error when sharing workbook

    Quote Originally Posted by DGagnon View Post
    try using this:

    Cells.Replace What:= _
    "'" & ActiveWorkbook.Path & "[" & ActiveWorkbook.Name & "]" _
    , Replacement:="'", LookAt:=xlPart, SearchOrder:=xlByRows, _
    MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
    Almost there, since I'm copying and pasteing from diferent workbooks the ActiveWorkbook.Name is not working right
    Take a look at my code
    nombre2 = Root & "\" & s
                Workbooks.Open (nombre2)
                librocopy = ActiveWorkbook.Name
                i = 5
                While Workbooks(librocopy).Worksheets("Manpower").Cells(i, 1).Value <> NullString
                    i = i + 1 'cuento los rengones a copiar
                Wend
                rangoCopy = "A5:AE" & i - 1
                Workbooks(librofinal).Activate
                Workbooks(s).Worksheets("Headcount").Range(rangoCopy).Copy _
                Destination:=Workbooks(librofinal).Worksheets("Manpower").Range("A" & a)
                cont = a
                cont = cont + (i - 5)
    where librofinal will be my consolidated and librocopy is the workbook I open to copy info to librofinal
    this is a loop that goes through all the files in a folder

  9. #9
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Consolidate macro then I get #REF formula error when sharing workbook

    you can get the original file name and path while you are in that book, just use this

    MyWorkbookName = "'" & ActiveWorkbook.Path & "[" & ActiveWorkbook.Name & "]"
    MyWorkbookName should be a string that you can use in your find replace.

  10. #10
    Registered User
    Join Date
    11-30-2009
    Location
    Mexico
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Consolidate macro then I get #REF formula error when sharing workbook

    Thanks for your help. its working now

  11. #11
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Consolidate macro then I get #REF formula error when sharing workbook

    no problem, glad to help.

+ Reply to Thread

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