LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default Loop not quite working correctly

Want to list the cell address in range OneRng of each blank.

As is, it list the first blank cell address only, but for as many times as there are cells in OneRng.

Thanks.
Howard


Sub OneRng_List_Blanks()

Dim c As Range, Rng As Range
Dim cBlnk$, sMsg$, vDataOut$
Dim blnkFnd As Boolean
Dim i As Long

Dim OneRng As Range, c As Range
Set OneRng = Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)

For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row
'For Each c In OneRng

Set Rng = OneRng.Find(What:="", _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns)
If Not Rng Is Nothing Then
blnkFnd = True

cBlnk = cBlnk & " " & Rng.Address

End If

'Next c
Next i

If blnkFnd Then
sMsg = "Blanks found on the following cells:"
sMsg = sMsg & vbLf & vbLf
sMsg = sMsg & Join(Split(Mid(cBlnk, 2), ","), vbLf)
Else
'Exit Sub
sMsg = "Blanks not found"
End If

MsgBox sMsg
End Sub
 
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
Macro not working correctly Andy_N1708 via OfficeKB.com Excel Discussion (Misc queries) 3 May 27th 10 03:35 AM
AutoSum not working correctly JimBUFF Excel Discussion (Misc queries) 2 November 9th 08 09:36 PM
WorksheetFunction not working correctly Ayo Excel Discussion (Misc queries) 1 July 23rd 08 05:48 PM
loop does not work correctly [email protected] Excel Programming 3 August 23rd 06 12:27 AM
Cursor not working correctly LSOT Excel Discussion (Misc queries) 4 November 1st 05 04:45 PM


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