PC Review


Reply
Thread Tools Rate Thread

Checking 2 Ranges

 
 
=?Utf-8?B?RGF2aXY=?=
Guest
Posts: n/a
 
      10th Apr 2007
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 With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      10th Apr 2007
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("G1414")) 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!

 
Reply With Quote
 
=?Utf-8?B?SmF5?=
Guest
Posts: n/a
 
      10th Apr 2007
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 With Quote
 
=?Utf-8?B?RGF2aXY=?=
Guest
Posts: n/a
 
      10th Apr 2007
Thanks both. It works beautifully.
--
Thanks!


"Jay" wrote:

> 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 With Quote
 
=?Utf-8?B?RGF2aXY=?=
Guest
Posts: n/a
 
      10th Apr 2007
Thanks for both. It works beautifully.
--
Thanks!


"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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Error Checking doesn't work on column ranges? genegal Microsoft Excel New Users 1 25th Jan 2010 05:19 AM
Checking if ranges are the same after Range.EntireColumn jc Microsoft Excel Programming 2 4th Jun 2008 10:18 PM
Checking for nonblank cells in ranges =?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?= Microsoft Excel Programming 3 13th Oct 2006 05:20 PM
Checking for named ranges in a workbook loopoo Microsoft Excel Programming 2 22nd Nov 2005 05:10 PM
Checking if Target is within different ranges =?Utf-8?B?TWF0dA==?= Microsoft Excel Programming 1 23rd Jul 2004 04:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:14 PM.