+ Reply to Thread
Results 1 to 4 of 4

Adjusting cell location of a variable

  1. #1
    Registered User
    Join Date
    09-10-2012
    Location
    Richmond, Virginia
    MS-Off Ver
    Excel 2010
    Posts
    2

    Adjusting cell location of a variable

    I am attempting to find a way to manipulate a cell reference of a variable. I was imagining using a variable as a range and adjust what that range is, but I have had absolutely no luck making that work.

    Specifically this is an example of what I want to do:

    Dim CellLocation as Range
    Set CellLocation = Range("A1")

    Now I want to be able to add/subtract from the current row/column so that I can change the cell reference. Let's say I wanted to be able to make it A2 without hard-coding it. So that every time the procedure is run, it moves down a row.

    I hope that I have explained that well. Maybe I need to make it something besides a range? I have been learning VBA for about 2 weeks now with no prior programming experience, so I am having a little trouble with simple things like this...

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Adjusting cell location of a variable

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    09-10-2012
    Location
    Richmond, Virginia
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Adjusting cell location of a variable

    That will do the trick.

    Thanks for the quick response!

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Adjusting cell location of a variable

    Quote Originally Posted by phillipsma3
    Let's say I wanted to be able to make it A2 without hard-coding it. So that every time the procedure is run, it moves down a row.
    Please Login or Register  to view this content.
    Last edited by jindon; 09-10-2012 at 09:56 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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