#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Row number

I have a macro to check a column to see if there are any blank cells. It
starts something like this:

For Each cell in Range("F2:F1001")
If cell.Value = "" Then
MsgBox " Please check row " & row number
End if
Next cell

Its the row number I cannot get.

Thanks in advance.

Gareth


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Row number

Gareth,

as a general hint, if you dimension things first, you will find it easier to
see properties and methods. I've also added an escape hatch to this so you
don't get 1000 message boxes in the event of an empty column.

Sub Test()
Dim rngCell As Range
For Each rngCell In Range("F2:F1001")
If IsEmpty(rngCell.Value) Then
MsgBox " Please check row " & rngCell.Row
Exit For
End If
Next rngCell
End Sub

--
Robin Hammond
www.enhanceddatasystems.com
Check out our XspandXL add-in


"Gareth" wrote in message
...
I have a macro to check a column to see if there are any blank cells. It
starts something like this:

For Each cell in Range("F2:F1001")
If cell.Value = "" Then
MsgBox " Please check row " & row number
End if
Next cell

Its the row number I cannot get.

Thanks in advance.

Gareth




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Row number

Hi Gareth,

Find the blank cells in the used range of the entire column F.

in Excel: Select Column F, Edit,Goto, blanks

recorded macro

Sub Macro17()
Columns("F:F").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
End Sub

Macro that you apparently are looking for:, find the empty
cells in column F within the Used Range ,
Ctrl+End identifies the last cell of the used range

Sub LoopEmptyF()
Dim cell As Range
Dim xRng As Range
On Error Resume Next
Set xRng = Columns("F:F").SpecialCells(xlCellTypeBlanks)
If xRng Is Nothing Then Exit Sub
On Error GoTo 0

For Each cell In Columns("F:F").SpecialCells(xlCellTypeBlanks)
MsgBox "Row is " & cell.Row & _
", and Column is " & cell.Column & "(" & _
Left(Cells(1, cell.Column).Address(0, 0), _
Len(Cells(1, cell.Column).Address(0, 0)) - 1) & ")"
Next cell
'-- same information without a loop ---
MsgBox Columns("F:F").SpecialCells(xlCellTypeBlanks).Addr ess(0, 0)
End Sub

--
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Gareth" wrote in message ...
I have a macro to check a column to see if there are any blank cells. It
starts something like this:

For Each cell in Range("F2:F1001")
If cell.Value = "" Then
MsgBox " Please check row " & row number
End if
Next cell

Its the row number I cannot get.

Thanks in advance.

Gareth




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
Sumif number is greater than a number but less than another number lulu151 Excel Discussion (Misc queries) 2 May 7th 10 07:12 PM
How can I click on a telephone number in an Excel 2002 spreadsheet, and have the number dialed? jbclem Excel Discussion (Misc queries) 2 August 13th 09 01:57 AM
How to calculate number of occurencies of a specific number number Stefan Excel Discussion (Misc queries) 4 September 8th 08 08:33 AM
Count number of times a specific number is displayed in a cell ran subs Excel Worksheet Functions 1 June 27th 05 05:01 PM
Rounding a number to a multiple quantity that adds to a fixed total number wjlo Excel Worksheet Functions 1 November 9th 04 04:43 PM


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