+ Reply to Thread
Results 1 to 4 of 4

Define Name use in Macros

  1. #1
    Bill Christian
    Guest

    Define Name use in Macros

    I am not sure how or if you can use the Define Name function in a worksheet
    to assign a value in an Macro. I am using the command below to assign a value
    in the worksheet in the macro. However the user might make changes to the
    worksheet that makes this method invalid. If I use the Define Name function
    in excel and create a Name can I then us it to assign a value?

    Set Total_Assets = Sheets("Balance Sheet").Range("H55")


  2. #2
    Jim Rech
    Guest

    Re: Define Name use in Macros

    You should definitely assign a name (Ctrl-F3) to this cell and all ranges
    your macros used, in case you or your users insert rows, etc.

    Set Total_Assets = Sheets("Balance Sheet").Range("TotAssets")


    --
    Jim
    "Bill Christian" <Bill Christian@discussions.microsoft.com> wrote in message
    news:9F053576-9105-4F32-8981-8AF995F4AB88@microsoft.com...
    |I am not sure how or if you can use the Define Name function in a worksheet
    | to assign a value in an Macro. I am using the command below to assign a
    value
    | in the worksheet in the macro. However the user might make changes to the
    | worksheet that makes this method invalid. If I use the Define Name
    function
    | in excel and create a Name can I then us it to assign a value?
    |
    | Set Total_Assets = Sheets("Balance Sheet").Range("H55")
    |



  3. #3
    KL
    Guest

    Re: Define Name use in Macros

    Hi Bill,

    Yes, you can and the sintax is identical:

    Set Total_Assets = Sheets("Balance Sheet").Range("MyDefinedName")


    Regards,
    KL



    "Bill Christian" <Bill Christian@discussions.microsoft.com> wrote in message
    news:9F053576-9105-4F32-8981-8AF995F4AB88@microsoft.com...
    >I am not sure how or if you can use the Define Name function in a worksheet
    > to assign a value in an Macro. I am using the command below to assign a
    > value
    > in the worksheet in the macro. However the user might make changes to the
    > worksheet that makes this method invalid. If I use the Define Name
    > function
    > in excel and create a Name can I then us it to assign a value?
    >
    > Set Total_Assets = Sheets("Balance Sheet").Range("H55")
    >




  4. #4
    Bill Christian
    Guest

    Re: Define Name use in Macros

    Thanks to Jim & KL. My macro is now more readable and bullet proof.

    "KL" wrote:

    > Hi Bill,
    >
    > Yes, you can and the sintax is identical:
    >
    > Set Total_Assets = Sheets("Balance Sheet").Range("MyDefinedName")
    >
    >
    > Regards,
    > KL
    >
    >
    >
    > "Bill Christian" <Bill Christian@discussions.microsoft.com> wrote in message
    > news:9F053576-9105-4F32-8981-8AF995F4AB88@microsoft.com...
    > >I am not sure how or if you can use the Define Name function in a worksheet
    > > to assign a value in an Macro. I am using the command below to assign a
    > > value
    > > in the worksheet in the macro. However the user might make changes to the
    > > worksheet that makes this method invalid. If I use the Define Name
    > > function
    > > in excel and create a Name can I then us it to assign a value?
    > >
    > > Set Total_Assets = Sheets("Balance Sheet").Range("H55")
    > >

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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