+ Reply to Thread
Results 1 to 13 of 13

Change from absolute to relative References with Excel Macro.

  1. #1
    Registered User
    Join Date
    11-28-2008
    Location
    Palembang
    Posts
    66

    Change from absolute to relative References with Excel Macro.

    Hello Bos ? anyone can help me, please..
    How to change from absolute references to relative references.

    Example :
    ws.Range("G" & NextRow).Formula = "=" & Range("H" & NextRow).Address & "+" & ws.Range("I" & NextRow).Address
    This code return the absolute references---> =$H$365+$I$365
    , and i want change to relative references, like this ---> =H365+I365

    Thank's b4
    Last edited by antoni; 09-14-2009 at 02:37 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Change from absolute to relative References with Excel Macro.

    Hi

    Instead of

    Please Login or Register  to view this content.
    that returns "$A$1", use

    Please Login or Register  to view this content.
    that returns "A1"

    HTH

  3. #3
    Registered User
    Join Date
    11-28-2008
    Location
    Palembang
    Posts
    66

    Re: Change from absolute to relative References with Excel Macro.

    Wows... nice code bos....
    Thank's for your help Mr. lecxe..

  4. #4
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Change from absolute to relative References with Excel Macro.

    Hi antoni,

    Try this:

    Please Login or Register  to view this content.
    BTW, you'll need to wrap your code (as lecxe and I have done) to comply with Rule 3 of the forum rules (see here for more info)

    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  5. #5
    Registered User
    Join Date
    11-28-2008
    Location
    Palembang
    Posts
    66

    Re: Change from absolute to relative References with Excel Macro.

    Hello bos, and how to use this formula with excel macro code, please..
    =ROUND(H365*I365/100;0)

    Thank's b4

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Change from absolute to relative References with Excel Macro.

    You need to be clearer with your questions.

    How do you want to use the formula - add to a sheet or within the code to get a value.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Change from absolute to relative References with Excel Macro.

    yo bro
    if you need to change a range of formulae use
    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  8. #8
    Registered User
    Join Date
    11-28-2008
    Location
    Palembang
    Posts
    66

    Re: Change from absolute to relative References with Excel Macro.

    example :
    Please Login or Register  to view this content.
    when i run this code, i get the error here :
    Run-time error '1004'
    Application-defined or object-defined error.

    thank's
    Last edited by royUK; 09-14-2009 at 02:42 AM. Reason: add code tags

  9. #9
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Change from absolute to relative References with Excel Macro.

    try removing the ; and replace it with ,
    Please Login or Register  to view this content.

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Change from absolute to relative References with Excel Macro.

    Antoni
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  11. #11
    Registered User
    Join Date
    11-28-2008
    Location
    Palembang
    Posts
    66

    Re: Change from absolute to relative References with Excel Macro.

    Yupzzz it's run bos. Thank's Mr. Pike

  12. #12
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Change from absolute to relative References with Excel Macro.

    sir will do..no problems
    can you edit your post and add the code tags as advised

  13. #13
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Change from absolute to relative References with Excel Macro.

    I've added Code Tags this time, read the Rules & follow themin future
    Please Login or Register  to view this content.

+ 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