| Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free! |
VBA/Excel Dynamic cell reference
|
Original Message
|
Name: quackadilly
Date: July 21, 2007 at 10:26:41 Pacific
Subject: VBA/Excel Dynamic cell referenceOS: XP proCPU/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?
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Razor2.3
Date: July 21, 2007 at 11:37:05 Pacific
|
Reply: (edit)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
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: quackadilly
Date: July 21, 2007 at 11:46:00 Pacific
|
Reply: (edit)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")
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: quackadilly
Date: July 21, 2007 at 12:12:56 Pacific
|
Reply: (edit)"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.
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: Razor2.3
Date: July 21, 2007 at 12:33:29 Pacific
|
Reply: (edit)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
Report Offensive Follow Up For Removal
|

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