Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cell Value Code

Status
Not open for further replies.

truitt20

Technical User
Dec 10, 2004
74
US
Here is my problem: I have two columns as below


CCH7 Cocoa, Mar 07
P.CCH71450 Cocoa, Mar 07 1450 Put
P.CFF7105 Coffee, Jan 07 1050 Put
C.CFH7135 Coffee, Mar 07 1350 Call
CTH7 Cotton, Mar 07
CTH7 Cotton, Mar 07
P.CTH750 Cotton, Mar 07 50 Put
C.SUH712 Sugar World #11, Mar 07 1200 Call

Column A holds the "product identifier" and column B is a result of dde link. Column B1 cell, for example, is "=CQGPC|CCH7!LongDescription" As you can see, the formula does not reference the cell, but rather the product identifier (in this example "CCH7") in the formula. I want to be able to write code so that I do not have to write out the long formula every single time I add a new product. Any ideas on how to have formula reference the column A cells?

any help is much appreciated.

thanks
 



HI,

Like this maybe...
[tt]
=INDIRECT("CQGPC|"&A1&"!LongDescription")
[/tt]


Skip,

[glasses] [red][/red]
[tongue]
 
Hmmm...tried that, but got the famed #REF! error
 
or simply use VBA to insert the desired formulas in Col B

range("B2").formula = """" & range("A2").value & "!LongDescription
 



and what does
[tt]
="CQGPC|"&A1&"!LongDescription"
[/tt]
return?

Skip,

[glasses] [red][/red]
[tongue]
 
thanks pbrosky! that works, but one other question:

How do i get a range to populate?

Range("B2:B100").Formula = "=CQGPC|" & Range("A2:A100").Value & "!LongDescription"?

that doesnt seem to work.
 
something like:
Sub zit()
For i = 2 To 20
txt = "CQGPC|" & Cells(i, 1).Value & "!LongDescription"
Cells(i, 2).Formula = txt
Next i
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top