+ Reply to Thread
Results 1 to 10 of 10

How do I make the following code similar to absolute refrence in formulas.

  1. #1
    Forum Contributor
    Join Date
    01-09-2016
    Location
    Surrey B.C.
    MS-Off Ver
    2013
    Posts
    155

    How do I make the following code similar to absolute refrence in formulas.

    Greetings

    I am constantly tweaking my spreadsheets. Everytime I add or subtract a row or colomn I have to rewrite the code to reflect these changes.

    For example, The following code selects cell "B4" then deletes the contents.

    Please Login or Register  to view this content.
    If I add a row or a column above, below or beside "B4" I have to change ("B4") to reflect this.

    For example, if I insert a row in Column "A", "B4" would have to be changed to "C4".

    Is there a way to write the code so that a I can make changes to the sheet without have to rewrite the code everytime?

    any help would be appreciates.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,502

    Re: How do I make the following code similar to absolute refrence in formulas.

    I believe you can use named ranges instead of cell references.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    01-09-2016
    Location
    Surrey B.C.
    MS-Off Ver
    2013
    Posts
    155

    Re: How do I make the following code similar to absolute refrence in formulas.

    Thank you
    I will have a go at it

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,502

    Re: How do I make the following code similar to absolute refrence in formulas.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  5. #5
    Forum Contributor
    Join Date
    01-09-2016
    Location
    Surrey B.C.
    MS-Off Ver
    2013
    Posts
    155

    Re: How do I make the following code similar to absolute refrence in formulas.

    I know how to make named ranges. I do not know how to use them, in order to, allow the sheet to have rows or colomns added or subtracted without having to change my code.
    Perhaps you could use the following "name range" in my example from my previous post.

    the defined name is "TAPERbead"

    the code is

    Please Login or Register  to view this content.
    Any help would be appreciated

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: How do I make the following code similar to absolute refrence in formulas.

    you can avoid using select altogether

    Please Login or Register  to view this content.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: How do I make the following code similar to absolute refrence in formulas.

    My VBA is weak, but I know there is a way to ID the active cell. Perhaps you could use that method, instead of using a hard-coded cell ref?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  8. #8
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: How do I make the following code similar to absolute refrence in formulas.

    to be honest i would just declare the range at the start of the code
    its easier to change it once at the start of the code then having to constantly re-code your whole work

    ie
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    01-09-2016
    Location
    Surrey B.C.
    MS-Off Ver
    2013
    Posts
    155

    Re: How do I make the following code similar to absolute refrence in formulas.

    I went with humdingaling first idea.
    it seemed simple enough.
    worked great t

    thank you

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: How do I make the following code similar to absolute refrence in formulas.

    Im happy you found what you wanted, and thanks for the feedback

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Code to make a Range of Cells Absolute
    By gorely84 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2018, 07:12 PM
  2. How to make references absolute in VBA code
    By kasun in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-07-2015, 01:49 AM
  3. code to add to end of macro to make the page keep values not formulas
    By scottatbuckman in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-26-2014, 04:38 PM
  4. How to make this code work for cells with formulas in them
    By daniellerhea in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-06-2013, 04:11 AM
  5. [SOLVED] See code enclosed - Convert to formulas with absolute reference inculding the sheet references!
    By Maria J-son in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-10-2005, 04:06 AM
  6. make formulas from relative to absolute
    By Barmaley in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-19-2005, 02:06 PM

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