VBA Cell Formula

T

Tony

I need to have the following code enter via VBA into a cell:

=IF(AH6="Active","",AH6)

I tried using the following but received an error:

wsPh.Range("ah" & Emcnt).Formula = "=if(ah" & Emcnt & ="Active"","" & ,"ah"
& Emcnt"")"

Can someone help me out here? Also, is there somewhere where I can see the
actual code format such a statement?

Many thanks,
 
J

Jacob Skaria

Range("A1").formula= "=IF(AH6=" & Chr(34) & "Active" & Chr(34) & "," &
Chr(34) & chr(34) & ",AH6)"

If this post helps click Yes
 
F

FSt1

hi
try this..
wsPh.Range("ah" & Emcnt).Formula = _
"=if(AH" & Emcnt & " =""Active"","",AH" & Emcnt & ")"

REgards
FSt1
 
J

Jacob Skaria

Range("A1").formula= "=IF(AH6=""Active"","""",AH6)"

If this post helps click Yes
 
T

Tony

Your statement came closest to the text formula I was using, but I am
receiving a run time 1004 error when I run the code. Any suggestions?
 
F

FSt1

opps. my bad.

wsPh.Range("ah" & emcnt).Formula = _
"=IF(AH" & emcnt & " =""Active"","""",AH" & emcnt & ")"

i forgot to put quotes around the quotes for the then part.

sorry.
regards
FSt1
 
T

Tony

That works like a charm. Much appreciated!

Tony

FSt1 said:
opps. my bad.

wsPh.Range("ah" & emcnt).Formula = _
"=IF(AH" & emcnt & " =""Active"","""",AH" & emcnt & ")"

i forgot to put quotes around the quotes for the then part.

sorry.
regards
FSt1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top