Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Count rows On error MsgBox

Hi
I need some lines of code to count the number of rows in
column A which includes blank cells.
If number of rows is greater than, less than 10 a MsgBox
with instructions should appear.
I'm importing a .txt file, deleting any blank rows and
adding/changing text and some formatting. When finished
the text should finish on row 10, ranging from cell A1 to
N10 no-more no-less.
The purpose is to indicate to the user, the original .txt
file did not contain 10 rows of text.
These lines of code will run at the end of macro.

I'm not sure how the Count, If true, if false, then, else
syntax should be laid out, and call up the MsgBox.

TIA

Bob C.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Count rows On error MsgBox

Hi Robert,

here is some code

Sub AnyBlanks()

If
Application.Evaluate("MAX((A1:A1000<"""")*ROW(A1: A1000))-COUNTA(A:A)") < 0
Then
MsgBox "There are empty cells"
End If

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Robert Christie" wrote in message
...
Hi
I need some lines of code to count the number of rows in
column A which includes blank cells.
If number of rows is greater than, less than 10 a MsgBox
with instructions should appear.
I'm importing a .txt file, deleting any blank rows and
adding/changing text and some formatting. When finished
the text should finish on row 10, ranging from cell A1 to
N10 no-more no-less.
The purpose is to indicate to the user, the original .txt
file did not contain 10 rows of text.
These lines of code will run at the end of macro.

I'm not sure how the Count, If true, if false, then, else
syntax should be laid out, and call up the MsgBox.

TIA

Bob C.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Count rows On error MsgBox

Hi Bob
Sorry, in my post the first line was misleading.
The mention of blank cells was to indicate the rows of
data in column A contained blank cells, not I wanted to
know if blank cells where there. The overall count of rows
should be 10 including blank cells ie A1 to last row
containing text has to count up to 10 even if say cells
A9 and A10 are blank.

HTH

Regards Bob C.


-----Original Message-----
Hi Robert,

here is some code

Sub AnyBlanks()

If
Application.Evaluate("MAX((A1:A1000<"""")*ROW

(A1:A1000))-COUNTA(A:A)") < 0
Then
MsgBox "There are empty cells"
End If

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Robert Christie"

wrote in message
...
Hi
I need some lines of code to count the number of rows

in
column A which includes blank cells.
If number of rows is greater than, less than 10 a

MsgBox
with instructions should appear.
I'm importing a .txt file, deleting any blank rows and
adding/changing text and some formatting. When finished
the text should finish on row 10, ranging from cell A1

to
N10 no-more no-less.
The purpose is to indicate to the user, the

original .txt
file did not contain 10 rows of text.
These lines of code will run at the end of macro.

I'm not sure how the Count, If true, if false, then,

else
syntax should be laid out, and call up the MsgBox.

TIA

Bob C.



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Count rows On error MsgBox

Dim rng as Range
set rng = Range("A1").CurrentRegion

if rng.Address(0,0) < "A1:N10" Then
msgbox "Bad data, data should fill A1:N10"
End if


or

Dim rng as Range
set rng = cells(rows.count,1).End(xlup)
if rng.row < 10 then
msgbox "Should be 10 rows of data"
End if


--
Regards,
Tom Ogilvy


"Robert Christie" wrote in message
...
Hi Bob
Sorry, in my post the first line was misleading.
The mention of blank cells was to indicate the rows of
data in column A contained blank cells, not I wanted to
know if blank cells where there. The overall count of rows
should be 10 including blank cells ie A1 to last row
containing text has to count up to 10 even if say cells
A9 and A10 are blank.

HTH

Regards Bob C.


-----Original Message-----
Hi Robert,

here is some code

Sub AnyBlanks()

If
Application.Evaluate("MAX((A1:A1000<"""")*ROW

(A1:A1000))-COUNTA(A:A)") < 0
Then
MsgBox "There are empty cells"
End If

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Robert Christie"

wrote in message
...
Hi
I need some lines of code to count the number of rows

in
column A which includes blank cells.
If number of rows is greater than, less than 10 a

MsgBox
with instructions should appear.
I'm importing a .txt file, deleting any blank rows and
adding/changing text and some formatting. When finished
the text should finish on row 10, ranging from cell A1

to
N10 no-more no-less.
The purpose is to indicate to the user, the

original .txt
file did not contain 10 rows of text.
These lines of code will run at the end of macro.

I'm not sure how the Count, If true, if false, then,

else
syntax should be laid out, and call up the MsgBox.

TIA

Bob C.



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Count rows On error MsgBox

Thanks Tom

All bases covered with your reply.
Thanks also for book info on a previous post.
With a Birthday coming up, I think John Walkenbach will
be on my bookshelf very soon.

Regards
Bob C.

-----Original Message-----
Dim rng as Range
set rng = Range("A1").CurrentRegion

if rng.Address(0,0) < "A1:N10" Then
msgbox "Bad data, data should fill A1:N10"
End if


or

Dim rng as Range
set rng = cells(rows.count,1).End(xlup)
if rng.row < 10 then
msgbox "Should be 10 rows of data"
End if


--
Regards,
Tom Ogilvy


"Robert Christie"

wrote in message
...
Hi Bob
Sorry, in my post the first line was misleading.
The mention of blank cells was to indicate the rows of
data in column A contained blank cells, not I wanted to
know if blank cells where there. The overall count of

rows
should be 10 including blank cells ie A1 to last row
containing text has to count up to 10 even if say cells
A9 and A10 are blank.

HTH

Regards Bob C.


-----Original Message-----
Hi Robert,

here is some code

Sub AnyBlanks()

If
Application.Evaluate("MAX((A1:A1000<"""")*ROW

(A1:A1000))-COUNTA(A:A)") < 0
Then
MsgBox "There are empty cells"
End If

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the

Purbecks
(remove nothere from the email address if mailing

direct)

"Robert Christie"


wrote in message
...
Hi
I need some lines of code to count the number of

rows
in
column A which includes blank cells.
If number of rows is greater than, less than 10 a

MsgBox
with instructions should appear.
I'm importing a .txt file, deleting any blank rows

and
adding/changing text and some formatting. When

finished
the text should finish on row 10, ranging from cell

A1
to
N10 no-more no-less.
The purpose is to indicate to the user, the

original .txt
file did not contain 10 rows of text.
These lines of code will run at the end of macro.

I'm not sure how the Count, If true, if false, then,

else
syntax should be laid out, and call up the MsgBox.

TIA

Bob C.



.



.

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
MsgBox when an Error occurs Vick Excel Discussion (Misc queries) 1 December 21st 05 08:48 PM
MsgBox compile error in Excell Jerry Dyben Excel Discussion (Misc queries) 1 October 11th 05 07:04 PM
Compile error for MsgBox copied from Microsoft training example? Jerry Dyben Excel Discussion (Misc queries) 2 October 11th 05 05:48 AM
msgbox on error Ciara Excel Discussion (Misc queries) 6 May 26th 05 08:34 PM
Count Records & Display MsgBox Donnie Stone Excel Programming 5 November 8th 03 04:13 AM


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

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"