Link to home
Start Free TrialLog in
Avatar of BarryOTO
BarryOTO

asked on

Trying to name a range of cells as "database" in a macro

When I try to name a range of cells as "database" in a marco sequence, Visual Basic gives me the following result:    

    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    ActiveWorkbook.Names.Add Name:="database", RefersToR1C1:= _
        "='2521'!R31C3:R6651C6"

My problem is I want to use the sequence with various different workbooks. This macro was created with an imported document named '2521' It seems if I want to use the macro with another document, Visual Basic still returns the information based on the earlier document namd.

I did select "relative reference" when I used the macro but that doesn't seem to solve the problem.

I would very much appreciate any help you could provide.

Thank you

Barry
ASKER CERTIFIED SOLUTION
Avatar of DennisBorg
DennisBorg

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
Avatar of BarryOTO
BarryOTO

ASKER

The answer gave me all the information I needed to solve my problem.
Thank you, Barry. I'm glad I could help.


-Dennis Borg