Need to re-initialize cell with original formula

  • Thread starter Thread starter Cinco
  • Start date Start date
C

Cinco

During an initialization process, I need to reset some cells to their
original formula(s). I tried the following w/o success. The cell contents
show as text afterwards rather than formulas. Help.
Jim

' Reset Session formulas to Full Night
Dim SessionCompareE3 As String
Dim SessionCompareF3 As String

SessionCompareE3 = "=COUNTIF(D8:D25000,"" > ""&B1)"
Range("$E$3").Select
ActiveCell.FormulaR1C1 = SessionCompareE3
SessionCompareF3 = "=COUNTIF(D8:D25000,"" < ""&C2)"
Range("$F$3").Select
ActiveCell.FormulaR1C1 = SessionCompareF3
 
Hi,

You are mixing cell reference types.
You use A1 notation to construct the formula string. But then assign it
to the R1C1 formula property.
Instead try,

ActiveCell.Formula = SessionCompareE3

You also need to remove the spaces from around the greater than sign.

SessionCompareE3 = "=COUNTIF(D8:D25000,"">""&B1)"

Cheers
Andy
 
Andy,
Your suggestions worked perfectly. Thanks.

Without any VBA background, I'm trying to learn things (especially when what
I try doesn't work and I become frustrated) by searching and reading posts on
this website. It is a slow process but, so far, no show stoppers!
Jim
 
Back
Top