Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help - Worksheet Function to Code


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

--
VBA Noo
-----------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...fo&userid=3383
View this thread: http://www.excelforum.com/showthread.php?threadid=56357

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Help - Worksheet Function to Code

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 Noob wrote:

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

--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=563576


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help - Worksheet Function to Code


Thanks Dav

--
VBA Noo
-----------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...fo&userid=3383
View this thread: http://www.excelforum.com/showthread.php?threadid=56357

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code Conflicts With Worksheet Change Code Paige Excel Programming 3 March 3rd 06 04:25 PM
Create a newworksheet with VBA code and put VBA code in the new worksheet module ceshelman Excel Programming 4 June 15th 05 04:37 PM
Worksheet Function using VB code Constantinos Kozakou Excel Programming 1 August 23rd 04 01:27 PM
Worksheet Function VB code error Bob[_56_] Excel Programming 1 May 12th 04 12:20 AM
vba code for lookup worksheet function Binoy[_2_] Excel Programming 1 December 13th 03 07:47 PM


All times are GMT +1. The time now is 12:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"