Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Missing Data in a Range

Is there a simple code to search a known range to verify
that each cell has correct data? The catch here is that
I always use columns A thru H, but do not know how many
rows it will be each time. So if I have complete
information on rows 2 - 5 (with row 1 as a header), then
I have only 1 column with data on row 6--it should
trigger a msgbox, etc...

I currently use a Do...Loop Until IsEmpty and then again
check the entire row, but this is quite slow in my
opinion, surely there could be a faster way.

Thanks if you could help, or let me know if I should
provide more detail.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Missing Data in a Range

Jeff

one way:

Sub Test()
Dim MaxRow As Long
Dim ExpectedCells As Long

MaxRow = WorksheetFunction.Max( _
Range("A65536").End(xlUp).Row, _
Range("B65536").End(xlUp).Row, _
Range("C65536").End(xlUp).Row, _
Range("D65536").End(xlUp).Row, _
Range("E65536").End(xlUp).Row, _
Range("F65536").End(xlUp).Row, _
Range("G65536").End(xlUp).Row, _
Range("H65536").End(xlUp).Row)

ExpectedCells = WorksheetFunction.CountA(Range("A1:H" & MaxRow))

If ExpectedCells < MaxRow * 8 Then
MsgBox "Incomplete data"
End If

End Sub

Regards

Trevor


"Jeff Green" wrote in message
...
Is there a simple code to search a known range to verify
that each cell has correct data? The catch here is that
I always use columns A thru H, but do not know how many
rows it will be each time. So if I have complete
information on rows 2 - 5 (with row 1 as a header), then
I have only 1 column with data on row 6--it should
trigger a msgbox, etc...

I currently use a Do...Loop Until IsEmpty and then again
check the entire row, but this is quite slow in my
opinion, surely there could be a faster way.

Thanks if you could help, or let me know if I should
provide more detail.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Missing Data in a Range

That is a good suggestion. It made me think

how about
if application.countA(Range("A:H")) mod 8 < 0 then
msgbox "Missing Data"
End if

--
Regards,
Tom Ogilvy

"Trevor Shuttleworth" wrote in message
...
Jeff

one way:

Sub Test()
Dim MaxRow As Long
Dim ExpectedCells As Long

MaxRow = WorksheetFunction.Max( _
Range("A65536").End(xlUp).Row, _
Range("B65536").End(xlUp).Row, _
Range("C65536").End(xlUp).Row, _
Range("D65536").End(xlUp).Row, _
Range("E65536").End(xlUp).Row, _
Range("F65536").End(xlUp).Row, _
Range("G65536").End(xlUp).Row, _
Range("H65536").End(xlUp).Row)

ExpectedCells = WorksheetFunction.CountA(Range("A1:H" & MaxRow))

If ExpectedCells < MaxRow * 8 Then
MsgBox "Incomplete data"
End If

End Sub

Regards

Trevor


"Jeff Green" wrote in message
...
Is there a simple code to search a known range to verify
that each cell has correct data? The catch here is that
I always use columns A thru H, but do not know how many
rows it will be each time. So if I have complete
information on rows 2 - 5 (with row 1 as a header), then
I have only 1 column with data on row 6--it should
trigger a msgbox, etc...

I currently use a Do...Loop Until IsEmpty and then again
check the entire row, but this is quite slow in my
opinion, surely there could be a faster way.

Thanks if you could help, or let me know if I should
provide more detail.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Missing Data in a Range

Tom

OK, that would work too ;-) And it is just a bit shorter than my version.

Regards

Trevor


"Tom Ogilvy" wrote in message
...
That is a good suggestion. It made me think

how about
if application.countA(Range("A:H")) mod 8 < 0 then
msgbox "Missing Data"
End if

--
Regards,
Tom Ogilvy

"Trevor Shuttleworth" wrote in message
...
Jeff

one way:

Sub Test()
Dim MaxRow As Long
Dim ExpectedCells As Long

MaxRow = WorksheetFunction.Max( _
Range("A65536").End(xlUp).Row, _
Range("B65536").End(xlUp).Row, _
Range("C65536").End(xlUp).Row, _
Range("D65536").End(xlUp).Row, _
Range("E65536").End(xlUp).Row, _
Range("F65536").End(xlUp).Row, _
Range("G65536").End(xlUp).Row, _
Range("H65536").End(xlUp).Row)

ExpectedCells = WorksheetFunction.CountA(Range("A1:H" & MaxRow))

If ExpectedCells < MaxRow * 8 Then
MsgBox "Incomplete data"
End If

End Sub

Regards

Trevor


"Jeff Green" wrote in message
...
Is there a simple code to search a known range to verify
that each cell has correct data? The catch here is that
I always use columns A thru H, but do not know how many
rows it will be each time. So if I have complete
information on rows 2 - 5 (with row 1 as a header), then
I have only 1 column with data on row 6--it should
trigger a msgbox, etc...

I currently use a Do...Loop Until IsEmpty and then again
check the entire row, but this is quite slow in my
opinion, surely there could be a faster way.

Thanks if you could help, or let me know if I should
provide more detail.







  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Missing Data in a Range

I think that is wonderful, can you help me understand
the "mod 8 < 0" part--seems that the 8 is in reference
to the "H", but what makes this work?
-----Original Message-----
That is a good suggestion. It made me think

how about
if application.countA(Range("A:H")) mod 8 < 0 then
msgbox "Missing Data"
End if

--
Regards,
Tom Ogilvy

"Trevor Shuttleworth" wrote

in message
...
Jeff

one way:

Sub Test()
Dim MaxRow As Long
Dim ExpectedCells As Long

MaxRow = WorksheetFunction.Max( _
Range("A65536").End(xlUp).Row, _
Range("B65536").End(xlUp).Row, _
Range("C65536").End(xlUp).Row, _
Range("D65536").End(xlUp).Row, _
Range("E65536").End(xlUp).Row, _
Range("F65536").End(xlUp).Row, _
Range("G65536").End(xlUp).Row, _
Range("H65536").End(xlUp).Row)

ExpectedCells = WorksheetFunction.CountA(Range("A1:H"

& MaxRow))

If ExpectedCells < MaxRow * 8 Then
MsgBox "Incomplete data"
End If

End Sub

Regards

Trevor


"Jeff Green"

wrote in message
...
Is there a simple code to search a known range to

verify
that each cell has correct data? The catch here is

that
I always use columns A thru H, but do not know how

many
rows it will be each time. So if I have complete
information on rows 2 - 5 (with row 1 as a header),

then
I have only 1 column with data on row 6--it should
trigger a msgbox, etc...

I currently use a Do...Loop Until IsEmpty and then

again
check the entire row, but this is quite slow in my
opinion, surely there could be a faster way.

Thanks if you could help, or let me know if I should
provide more detail.





.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Missing Data in a Range

16 mod 8 would return 0. Mode gives you the remainder of dividing 16 by 8
(in the example). since each row should have 8 entries, and countA counts
the cells with entries, one would expect that a square - filled range of 8
columns should have a countA evenly divisible by 8.

--
Regards,
Tom Ogilvy

wrote in message
...
I think that is wonderful, can you help me understand
the "mod 8 < 0" part--seems that the 8 is in reference
to the "H", but what makes this work?
-----Original Message-----
That is a good suggestion. It made me think

how about
if application.countA(Range("A:H")) mod 8 < 0 then
msgbox "Missing Data"
End if

--
Regards,
Tom Ogilvy

"Trevor Shuttleworth" wrote

in message
...
Jeff

one way:

Sub Test()
Dim MaxRow As Long
Dim ExpectedCells As Long

MaxRow = WorksheetFunction.Max( _
Range("A65536").End(xlUp).Row, _
Range("B65536").End(xlUp).Row, _
Range("C65536").End(xlUp).Row, _
Range("D65536").End(xlUp).Row, _
Range("E65536").End(xlUp).Row, _
Range("F65536").End(xlUp).Row, _
Range("G65536").End(xlUp).Row, _
Range("H65536").End(xlUp).Row)

ExpectedCells = WorksheetFunction.CountA(Range("A1:H"

& MaxRow))

If ExpectedCells < MaxRow * 8 Then
MsgBox "Incomplete data"
End If

End Sub

Regards

Trevor


"Jeff Green"

wrote in message
...
Is there a simple code to search a known range to

verify
that each cell has correct data? The catch here is

that
I always use columns A thru H, but do not know how

many
rows it will be each time. So if I have complete
information on rows 2 - 5 (with row 1 as a header),

then
I have only 1 column with data on row 6--it should
trigger a msgbox, etc...

I currently use a Do...Loop Until IsEmpty and then

again
check the entire row, but this is quite slow in my
opinion, surely there could be a faster way.

Thanks if you could help, or let me know if I should
provide more detail.




.



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
filter for missing values in a range billnock Excel Discussion (Misc queries) 1 January 30th 10 11:01 PM
Missing Blue Border in xml mapped range Babba Excel Discussion (Misc queries) 0 October 26th 06 11:54 AM
Missing blank in Dynamic range Graham Haughs Excel Worksheet Functions 5 August 4th 06 10:59 PM
Rounding a large range & a Missing Font Jay New Users to Excel 1 May 21st 06 06:50 PM
Advanced Filtering Extract Range Missing,etc bridges_22 Excel Worksheet Functions 1 February 6th 06 04:19 PM


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