LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Casey
 
Posts: n/a
Default Help getting count of non-blank cells


Hi,
I am attempting to count the non-blank cells in an 8 cell range and
failing miserably. I have included in the code below a couple of other
avenues I've tried. They are commented out. Setting a watch on colindex
and cnt show that colindex is looping as expected, however the cnt seems
to only pick up formula cells. I need it to cnt any cell in the range
that contains any input.

Here is the Code

Private Sub CommandButton4_Click()
Dim rngEntryBottomRow As Range
Dim Msg As Integer
Dim Response As Integer
Dim colIndex As Integer
Dim cnt As Integer

Application.EnableEvents = False
Application.ScreenUpdating = False

Set rngEntryBottomRow = Range("Below_Entry_Bottom_Row").Offset(-1)
cnt = 0
For colIndex = 1 To 8
With rngEntryBottomRow.Cells(0, colIndex)
If .HasFormula Or .Value 0 Then cnt = cnt + 1
'Here are two other iterations I have tried.
'If .HasFormula Or .Text < "" Then cnt = cnt + 1
'If
Application.WorksheetFunction.CountA(rngEntryBotto mRow.Cells(0,
colIndex)) = 1 Then cnt = cnt + 1
End With
Next colIndex

If cnt 3 Then
Msg = MsgBox("You are attempting to Delete a Row that contains User
Input." _
& " Delete Row Failed", vbOKOnly + vbCritical, "Can Not Delete Row
with Information")
If Response = 1 Or 2 Then GoTo RET
End If
If cnt = 3 Then
With rngEntryBottomRow
.EntireRow.Delete
End With
End If

RET:
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub


--
Casey


------------------------------------------------------------------------
Casey's Profile: http://www.excelforum.com/member.php...fo&userid=4545
View this thread: http://www.excelforum.com/showthread...hreadid=543101

 
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
count non blank cells with criteria UT Excel Discussion (Misc queries) 5 April 25th 06 07:37 PM
Counting blank cells until value is reached Dan Excel Worksheet Functions 9 March 1st 06 12:56 PM
count number of cells bill gras Excel Worksheet Functions 4 October 3rd 05 07:15 AM
Generating truly blank cells Nat Excel Worksheet Functions 4 September 30th 05 11:39 PM
formula to count cells not blanK pmarques Excel Worksheet Functions 4 August 3rd 05 01:44 PM


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