Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Looping through cell

This has to have been addressed before but I'm having some problems
and I was hoping a guru could help me.

I have a column whose row size is variable. In some of the cells for
that column, there is a blank or null value. I want to place NA in
that value and iterate through the cell until the end.

I seem to be able to get the columns row size but I can't seem to
iterate through each cell and check for the null value.

Here is an example of the row:
J
--------
Mod%

..123
..345
..234

..234

..234 [end]

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Looping through cell

It's not clear what you want, but I'll take a guess.

Dim r as Range, myRange as Range

set myRange = range("C1") '<~~~first cell in range
lRow = cells(rows.count,myrange.column).end(xlup).row

Set myRange = myRange.resize(lRow - myRange.row + 1,1)

For each r in myRange
If isempty(r) then
r.formulaR1C1 = "=NA()"
'or
'r.value = "NA"
end if
next r

HTH,
Barb Reinhardt

" wrote:

This has to have been addressed before but I'm having some problems
and I was hoping a guru could help me.

I have a column whose row size is variable. In some of the cells for
that column, there is a blank or null value. I want to place NA in
that value and iterate through the cell until the end.

I seem to be able to get the columns row size but I can't seem to
iterate through each cell and check for the null value.

Here is an example of the row:
J
--------
Mod%

..123
..345
..234

..234

..234 [end]


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Looping through cell

Sub foo()
Dim rng1 As Range
Set rng1 = Range(ActiveCell, Cells(Rows.Count, ActiveCell.Column).End(xlUp))
For Each cell In rng1
If cell.Value = "" Then
cell.Value = "NA"
End If
Next cell
End Sub


Gord Dibben MS Excel MVP


On 27 May 2007 11:14:11 -0700, " wrote:

This has to have been addressed before but I'm having some problems
and I was hoping a guru could help me.

I have a column whose row size is variable. In some of the cells for
that column, there is a blank or null value. I want to place NA in
that value and iterate through the cell until the end.

I seem to be able to get the columns row size but I can't seem to
iterate through each cell and check for the null value.

Here is an example of the row:
J
--------
Mod%

.123
.345
.234

.234

.234 [end]


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
looping through variable defined cell [email protected] Excel Programming 0 September 8th 06 04:31 AM
Looping in VB with cell ranges Freeman Excel Worksheet Functions 2 January 22nd 06 12:14 PM
Faster Way of looping through cell values Andibevan Excel Discussion (Misc queries) 1 August 12th 05 03:10 PM
Looping and Testing Cell Values [email protected] Excel Programming 1 July 20th 05 04:29 PM
Cell References and Looping KPaul Excel Programming 2 October 4th 03 04:13 PM


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