Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Checking 2 Ranges

I want to check the completeness of a report. If one of the cell in Range
"D14:F14" is not blank then one of the cell in "G14:H14" should also be not
blank, vice versa. Below is my code and it is not working. Thanks in
advance.

Set SThree(0, 0) = .Range("D14:F14")
Set SThree(0, 1) = .Range("G14:H14")

For Each Cell In SThree(0, 0)
If Cell < "" Then
For Each Cells In SThree(0, 1)
If Cells = "" Then
MsgBox "Not Complete"
Cancel = True
Exit Sub
Else
Cancel = True
Exit Sub
End If

Next
Next
--
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Checking 2 Ranges

I don't know if < is the right test since there are different numbers of
cells - but maybe this will give you ideas:

if application.CountA(.Range("D14:F14")) < Application.CountA( _
.Range("G14:D14")) then
MsgBox "Not Complete"
Cancel = True
Exit Sub
end if

--
Regards,
Tom Ogilvy






"Daviv" wrote:

I want to check the completeness of a report. If one of the cell in Range
"D14:F14" is not blank then one of the cell in "G14:H14" should also be not
blank, vice versa. Below is my code and it is not working. Thanks in
advance.

Set SThree(0, 0) = .Range("D14:F14")
Set SThree(0, 1) = .Range("G14:H14")

For Each Cell In SThree(0, 0)
If Cell < "" Then
For Each Cells In SThree(0, 1)
If Cells = "" Then
MsgBox "Not Complete"
Cancel = True
Exit Sub
Else
Cancel = True
Exit Sub
End If

Next
Next
--
Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Checking 2 Ranges

Hi Daviv -

Here's some replacement code. Adapt as necessary:

a = Application.CountA(Range("D14:F14"))
b = Application.CountA(Range("G14:H14"))
If (a 0 And b = 0) Or (b 0 And a = 0) Then
MsgBox "Not Complete"
Cancel = True
Exit Sub
Else
MsgBox "aok" '<<====Delete after testing
Cancel = True
Exit Sub
End If

--
Jay


"Daviv" wrote:

I want to check the completeness of a report. If one of the cell in Range
"D14:F14" is not blank then one of the cell in "G14:H14" should also be not
blank, vice versa. Below is my code and it is not working. Thanks in
advance.

Set SThree(0, 0) = .Range("D14:F14")
Set SThree(0, 1) = .Range("G14:H14")

For Each Cell In SThree(0, 0)
If Cell < "" Then
For Each Cells In SThree(0, 1)
If Cells = "" Then
MsgBox "Not Complete"
Cancel = True
Exit Sub
Else
Cancel = True
Exit Sub
End If

Next
Next
--
Thanks!

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
Excel Error Checking doesn't work on column ranges? genegal New Users to Excel 1 January 25th 10 05:19 AM
Checking for nonblank cells in ranges Barb Reinhardt Excel Programming 3 October 13th 06 05:20 PM
Checking range of cells for entry then checking for total Barb Reinhardt Excel Programming 1 October 13th 06 02:47 PM
Checking for named ranges in a workbook loopoo[_17_] Excel Programming 2 November 22nd 05 05:10 PM
Checking if Target is within different ranges Matt Excel Programming 1 July 23rd 04 04:18 PM


All times are GMT +1. The time now is 10:47 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"