LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default Search a range for a value

Below is my code. It is supposed to look for the value "999" in the two
ranges specified and if "999" is in either range give the message box.
However, it doesn't seem to be working. Here are a couple possible problems.
Other values are in some of the cells in the target range (i.e. "898").
Everyother cell in the target range is merged together (i.e. AD18 and AD19
are merged into one cell). Please advise.

Dim x As Boolean
With Application
x = .CountIf(Sheets("T.S. (2)").Range("AD18:AD44"), 999) +
..CountIf(Sheets("T.S. (2)").Range("AD67:AD99"), 999)
End With

If x = True Then

Msg = "This employee has included the 999 code on his/her time
sheet! Is this a 75 hour leave without pay time sheet?"
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbYes Then
With Worksheets("Worksheet")
.Range("B9:I15,L9:S15,V4").Value = 0
End With
End If
If Ans = vbNo Then
Msg = "Please remove the 999 code from their time sheet."
Ans = MsgBox(Msg, vbOKOnly)
ActiveWindow.ActivateNext
End If
End If
--
Thanks
Shawn
 
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
Search range for text not in another range simon howard Excel Discussion (Misc queries) 3 March 28th 07 08:44 PM
How to search a range for a suburb in a large range Bogan.. Excel Programming 2 June 22nd 05 01:20 PM
Can I search a range Imajesty Excel Programming 3 April 7th 05 09:53 PM
Search for #'s in range kinga Excel Programming 9 March 14th 05 09:45 PM
Search a value in particular range Garima[_2_] Excel Programming 1 April 16th 04 05:46 AM


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

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

About Us

"It's about Microsoft Excel"