Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Number of Rows in Column

Status
Not open for further replies.

Eytch

Programmer
Jan 29, 2003
60
US
I want to execute a For/Next Loop for all the Rows in a column.

For rwindex = 1 to (Number of Rows in the column)

How do I get a count of the number of rows in the column for the above statement. If the criteria are met in the for statement I want that row deleted and the subsequent empty row edited out of the column. I want a continuous column of data in the end that does not meet any of the criteria in the For/Next statement - any cells that did meet the criteria are deleted from the column.

Thanks for your help.
I tried what follows but can't get the number of the last row of the column containing data. How do I find the value of intRows?

For rwIndex = 1 To intRows

For colIndex = 1 To 1
Dim MyVal


With Worksheets("Sheet1").Cells(rwIndex, colIndex)

MyVal = Worksheets("Sheet1").Cells(rwIndex, colIndex)
If .Value < 1 Or IsNumeric(MyVal) = False Then .Value = 0
End With
Next colIndex
Next rwIndex
 
Hi,

If your list is contiguous and isolated from data in other columns
Code:
dim r as range
for each r in [a1].currentregion
  with r
   If .Value < 1 Or IsNumeric(.Value) = False Then .Value = 0
  End With  
next
:)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
How do I get a count of the number of rows in the column
Take a look in the FAQ area

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top