Computing.Net > Forums > Programming > VBA/Excel Dynamic cell reference

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VBA/Excel Dynamic cell reference

Reply to Message Icon

Name: quackadilly
Date: July 21, 2007 at 10:26:41 Pacific
OS: XP pro
CPU/Ram: AMD64
Comment:

I'm trying to reference a alue that is stored in a cell.

Cell "S1" has the value "J2" stored in it.

in VBA I'm using this code:

cell = Sheets("Form").Range("S1")
Sheets("Archive").Range(cell).Paste

but it isn't working. How do you do this?




Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: July 21, 2007 at 11:37:05 Pacific
Reply:

What are you attempting? Do you want to copy the value from cell Form.S1 to cell Archive.S1?

Sheets("Archive").Range("S1").Formula = Sheets("Form").Range("S1").Formula


0

Response Number 2
Name: quackadilly
Date: July 21, 2007 at 11:46:00 Pacific
Reply:

cell "S1" is essentially a *pointer. In this example is contains the value "J2", which is where I want to paste my data.

the value in "S1" is determining where the number in "E15" is going.("J2")


0

Response Number 3
Name: Razor2.3
Date: July 21, 2007 at 11:52:49 Pacific
Reply:

So, do you want it to grab the "pointer," make a new "pointer," or the final value?


0

Response Number 4
Name: quackadilly
Date: July 21, 2007 at 12:12:56 Pacific
Reply:

"S1" is pointing to the cell where the final value is placed.

"E15" has the value 1.
"S1" has the value "J2".
I want "J2" to have the value of 1.

But the value of "S1" changes and VBA won't let me use the code in my first post.


0

Response Number 5
Name: Razor2.3
Date: July 21, 2007 at 12:33:29 Pacific
Reply:

Of course it doesn't let you use your code; the flow of logic is incompatible with VBA. I'm surprised it actually compiled. After all, after I read it, I had to ask you what you wanted.

This line (It's really one line; I blame the line wrapping, myself.) will copy whatever is displayed in the cell "S1" (and not the pointer itself):
Sheets("Archive").Range("J2").Formula = Sheets("Form").Range("S1").Value

If you wanted the pointer, I'd just drop the VBA attempt and change J2's formula to read:
=Form!$S$1


0

Related Posts

See More



Response Number 6
Name: quackadilly
Date: July 21, 2007 at 13:07:37 Pacific
Reply:

But it won't always point to "J2". That's the problem.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VBA/Excel Dynamic cell reference

VBA (Excel) Editing Cells www.computing.net/answers/programming/vba-excel-editing-cells/4698.html

VB Script To Prompt For Cell Reference www.computing.net/answers/programming/vb-script-to-prompt-for-cell-reference/19836.html

VBA Cell reference www.computing.net/answers/programming/vba-cell-reference/18824.html