Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default doing COUNTIF() in code

I was using the countif function to see if there was one "X" in th
E4:E3310 range.
(COUNTIF($E$4:$E$3310,"=X")) = 1
It works fine.

Now I need to use the same results to process some code.
But of course the IF statement in the following will not work:
----------------------------------------------------------------------
If ((COUNTIF($E$4:$E$3310,"=X"))= 1) Then

Sheets("wsheet").Select

Sheets("wsheet").Range("A5:j100").ClearContents
' additional stuff goes here

Exit Sub
End If

MsgBox "Please select one."
----------------------------------------------------------------------

Can you help me fix the above code so that it works

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default doing COUNTIF() in code

Lothario,

Sub test()
If WorksheetFunction.CountIf(Range("$E$4:$E$3310"), "X") = 1 Then
MsgBox "Hello"
End If
End Sub

Rob


"lothario " wrote in message
...
I was using the countif function to see if there was one "X" in the
E4:E3310 range.
(COUNTIF($E$4:$E$3310,"=X")) = 1
It works fine.

Now I need to use the same results to process some code.
But of course the IF statement in the following will not work:
----------------------------------------------------------------------
If ((COUNTIF($E$4:$E$3310,"=X"))= 1) Then

Sheets("wsheet").Select

Sheets("wsheet").Range("A5:j100").ClearContents
' additional stuff goes here

Exit Sub
End If

MsgBox "Please select one."
----------------------------------------------------------------------

Can you help me fix the above code so that it works?


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default doing COUNTIF() in code

Thanks Rob


---
Message posted from http://www.ExcelForum.com/

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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
What's the vba code equivalent for Countif NDBC Excel Discussion (Misc queries) 3 July 4th 09 11:42 AM
how to do a countif - want cells that are before or on a certain dateand do not want to hard code that date SK08 Excel Worksheet Functions 1 December 2nd 08 05:26 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
COUNTIF TO BUILD SIMPLE CODE Eddy Stan Excel Worksheet Functions 6 August 26th 07 11:06 PM


All times are GMT +1. The time now is 02:29 PM.

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"