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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a formula in a cell that refers to another cell... Not using 'Range' tho 2

Status
Not open for further replies.

MattGreer

Technical User
Feb 19, 2004
471
US
I've always had issues with 'Range', something about it has always frustrated and confused me, so for this particular bit of code I'm using "Cells" which makes complete and total sense to me, heh. Anyway...

In Excel 365 I'm running down a series of rows. I check in Column 8 and if there's a double quote → " then I want to add a formula to Column 9 that refers to Column 8. I'm not certain how to do this. The formula is a custom function to convert Feet and Inches to decimal feet.


Code:
'Somewhere at the top of the code I have this:
[indent]dq = Chr(34) 'double quote as a variable[/indent]
[indent]iLength = 9 'just so I can refer to the column easier[/indent]
[indent]iQty = 8 'just so I can refer to the column easier[/indent]

'Then later on...
        If InStr(1, Cells(iRow, iQty), dq) Then
            'Add the calc to column 9
            Cells(iRow, iLength).Formula = "=StringToFt(" &
        End If

So what goes after "=StringToFt(" ?



Thanks!!


Matt
 
Did you hear that slapping sound? That was me smacking my forehead... :)

Thank you!

Thanks!!


Matt
 
I might have mis-typed it, I'm getting the error: "Run-time error '1004': Application-defined or object-defined error"

I'll update/edit this post if I figure out it's my error. This is the line of code:

Cells(iRow, iLength).Formula = "=StringToFt(" & Cells(iRow, iQty).Address

When I type the formula in manually, it works.

Any ideas?


edit: I forgot the closing paren. Do you hear that slapping sound again? My forehead is taking a beating today. :)


Thanks!!


Matt
 
I can see Matt going [banghead]
"convert Feet and Inches to decimal feet" - join at least XIX century and go metric. [lol]

Looks like you can use your [tt]StringToFt[/tt] function 'directly' (not as a formula):

Code:
Cells(iRow, iLength).[blue]Value[/blue] = [red]StringToFt[/red](Cells(iRow, iQty).[blue]Value[/blue])

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Andrzejek,

That's not a bad idea really. I'm not sure if I should leave it in there or not. I think I like your idea better, but hey, I learned something so... Win Win!


Thanks!!


Matt
 
I have always thought going metric is a very good idea. [wiggle]

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Andy said:
I have always thought going metric is a very good idea.

So did my son's sixth grade teacher in 1979, when she unilaterally decided NOT to teach English system conversions but only metric conversions (moving a decimal point) BECAUSE she wholeheartedly believed that the US was going to convert to metric in 1980.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
As an engineer, metric is amazing. That's all I have to say about that. :)

Thanks!!


Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top