Share via

Consolidate active sheet using macro

Anonymous
2018-01-11T18:16:33+00:00

I am trying to consolidate some data in the current active sheet using a macro.  However my macro keeps referring back to the original sheet that I used to record it.  How can I change the macro so that it always consolidates the range of cells in the active sheet?

Currently the VBA code reads:

Range("O2").Select   

Selection.Consolidate Sources:= _

        "'C:\Users\Sales1\Desktop[TEST FOR RACK - Copy.XLSX]Sheet'!R2C12:R3000C13", _

        Function:=xlSum, TopRow:=True, LeftColumn:=True, CreateLinks:=False

Any help would be greatly appreciated!

Thanks,

Ben

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

5 answers

Sort by: Most helpful
  1. Anonymous
    2018-01-11T18:21:42+00:00

    Hi,

    Please use following code

    [Code]

    Range("O2").Select
    

    Selection.Consolidate Sources:= _

    "'C:\Users\Sales1\Desktop[TEST FOR RACK - Copy.XLSX]" & ActiveWorkbook.Name & "'!" & ActiveCell.Name, _

    Function:=xlSum, TopRow:=True, LeftColumn:=True, CreateLinks:=False

    GetATPUICultureTag = sCulture
    

    Let me know if that helps.

    Kind Regards,

    Engr. Jamshed Muhammad

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2018-01-11T19:14:59+00:00

    It keeps saying:

    Cannot open consolidation source file

    Ben

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2018-01-11T19:10:28+00:00

    Hi,

    Range("O2").Select 
    Selection.Consolidate Sources:= _ 
    "'C:\Users\Sales1\Desktop\[TEST FOR RACK - Copy.XLSX]" & ActiveWorkbook.Name & "'!'!L2:M3000", _ 
    Function:=xlSum, TopRow:=True, LeftColumn:=True, CreateLinks:=False 
    GetATPUICultureTag = sCulture 
    

    Use this code.

    Let me know if that helps.

    Kind Regards,

    Engr. Jamshed Muhammad

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2018-01-11T19:07:44+00:00

    Jamshed,

    Thank you, but pasting that code did not work.  Again, I want to completely ignore the original sheet and just consolidate L2:M3000 of the active worksheet only.

    Any thoughts?

    Ben

    Was this answer helpful?

    0 comments No comments
  5. Vijay A. Verma 104.9K Reputation points Volunteer Moderator
    2018-01-11T18:24:58+00:00

    The macro will have to be rewritten. For this, I need a sample workbook.

    Request you to please prepare and upload a sample / dummy file sans confidential / sensitive data to Onedrive and share the link? It will help me to give prompt and high quality solution.

    Was this answer helpful?

    0 comments No comments