+ Reply to Thread
Results 1 to 3 of 3

Using code with changing cell references

  1. #1
    Registered User
    Join Date
    08-07-2006
    Posts
    31

    Using code with changing cell references

    Hi folks

    When I'm creating a worksheet the value I'm working with is in cell A1. However, at some point this may change to another cell, and then to another.

    When I'm writing my code I don't want to have to keep changing the Range reference every time I move the required cell value about on the worksheet.

    Is it possible to do something like TargetCell = Range ("A1") and then I can use TargetCell in my code whenever I'm using this cell.

    Then if at some point I move cell A1 to cell B14 on my worksheet I only have to change this one line in my code rather than search for all references to Range ("A1")

    Hope I've explained this OK.

    Cheers

    Chard

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    If you mean the value of A1 then

    Please Login or Register  to view this content.
    will give you that.
    The prefered code is
    Please Login or Register  to view this content.
    You then can use
    Please Login or Register  to view this content.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Valued Forum Contributor
    Join Date
    04-11-2006
    Posts
    407
    If I understand you correctly this should work
    Please Login or Register  to view this content.
    So will have to do a little changing around in your code initially, but from there on out will only have to change the "myTargetCell" value.

+ 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