View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1431_] Rick Rothstein \(MVP - VB\)[_1431_] is offline
external usenet poster
 
Posts: 1
Default Enter NA() into All Blank Cells in Range

See inline...

"ryguy7272" wrote in message
...
Yeah, ticking out that n was a mistake. This is what I have now:
CountRows = Sheets("INPUTS").Range("AA1")
Range("A65536").Select
Selection.End(xlUp).Select
Range(ActiveCell.Offset(0, 1), ActiveCell.Offset(0, 4)).Select
Range(Selection, "B3:E3").Select


If I am reading your code correctly, when you execute the next lines below,
nothing you did in the code above matters (nor is it necessary for what you
want to ultimately do).

n = Cells(Rows.Count, 1).End(xlUp).Row
Set r = Range("B3:E" & n)
For Each rr In r
If IsEmpty(rr.Value) Then
rr.Formula = "=NA()"
End If
Next

Almost there, but not quite. B3:E3 fills in fine, and many of the cells
below fill in fine, but it fails when it gets to the cell above the cell
in
Column A, where the dates are, if the dates don't go to the top. For
instance, sometimes the dates will begin in A46, I don't have any data for
B46:E46, so these cells are blank, but I do have data for B47:E47 down to
b390:E390. Then D391:E391 are blank but B391:C391 down to B597:C597 has
data
-- D597:E597 are blank so I would like to fill these with =NA(). The
entire
range is selected, and it seems like the sub should fill in all blanks
with
=NA(), but it gets stuck at the top and never makes its way down...


Do me a favor... comment out all the current code (shown above) and replace
it with this code...

n = Cells(Rows.Count, 1).End(xlUp).Row
Set R = Range("B3:B" & n).SpecialCells(xlCellTypeBlanks)
For Each rr In R
rr.Formula = "=NA()"
Next

and tell me if it does what you want.

Rick