Help - Worksheet Function to Code

  • Thread starter Thread starter VBA Noob
  • Start date Start date
V

VBA Noob

Hi all,

I don't think I should be using a Worksheet function but didn't kno
how to code it.

I want to check to see if a range has a entry and if it does it clear
A1 to I5. It works if I put the formula into a cell but not as it.

Thanks for any Help

Sub Macro4()


myVal = ActiveSheet.Evaluate(sFormula)
sFormula = Selection.FormulaArray
"=IF(OR(RC[-8]:R[4]C[-2]<>""""),TRUE,FALSE)"

If sFormula = True Then
Range("A1:I5").ClearContents
End If
End Sub

VBA Noo
 
If you're checking to see if a range is non-empty, then you clear it, you could
just clear it without checking.

somerange.clearcontents

if you're looking a one range and if it's got something in it, then you clear a
different range:

dim rng1 as range
dim rng2 as range

if application.counta(rng1) > 0 then
rng2.clearcontents
end if

===
If rng1 was a single cell:
if isempty(rng1.value) then
'it's empty
else
rng2.clearcontents
end if


VBA said:
Hi all,

I don't think I should be using a Worksheet function but didn't know
how to code it.

I want to check to see if a range has a entry and if it does it clears
A1 to I5. It works if I put the formula into a cell but not as it.

Thanks for any Help

Sub Macro4()

myVal = ActiveSheet.Evaluate(sFormula)
sFormula = Selection.FormulaArray =
"=IF(OR(RC[-8]:R[4]C[-2]<>""""),TRUE,FALSE)"

If sFormula = True Then
Range("A1:I5").ClearContents
End If
End Sub

VBA Noob
 
Back
Top