View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
ryguy7272 ryguy7272 is offline
external usenet poster
 
Posts: 2,836
Default Enter NA() into All Blank Cells in Range

The MsgBox says 2
Also, I think the cells are empty.
=code(B4) gives me: #VALUE

--
RyGuy


"Gary''s Student" wrote:

Actually, the fact that B3 got filled is good news. It means theat we can
start to de-bug.

First put a:
MsgBox(n)
right after :
n = Cells(CountRows, 1).End(xlUp).Row

just to make sure n is good



Second, check that the cells in column B are really empty
--
Gary''s Student - gsnu200773


"ryguy7272" wrote:

Hummm, seems like it should work, but it is not working. This is what I am
using now:

CountRows = Sheets("INPUTS").Range("AA1")
n = Cells(CountRows, 1).End(xlUp).Row
Set r = Range("B3:B" & n)
For Each rr In r
If IsEmpty(rr.Value) Then
rr.Formula = "=NA()"
End If
Next

The inputs screen has this function in AA1:
=COUNTA('GRAPH CURRENT'!A2:A65536)

In my current example, I counted down 596 rows, and then try to offset (0,
1), but it doesnt work. All I get is a =NA() in cell B3. What did I do
wrong?


Thanks,
Ryan--


--
RyGuy


"Gary''s Student" wrote:

Consider:

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

this sub:

1. finds the end of column A
2. creates a range from B3 thru the row found in step #1
3. fills the empty cells in the range with the formula.
--
Gary''s Student - gsnu200772


"ryguy7272" wrote:

I have dates in Column A, and data in Column B:E.

I am using this little snippet of code to insert NA into cells to force my
graph to plot correctly:

Sheets("GRAPH CURRENT").Select
MyVar = ""
For Each Item In Range("B3:E3")
If Item.Value = MyVar Then Item.Value = "=NA()"
Next Item

The graph is based on this tip:
http://j-walk.com/ss/excel/usertips/tip024.htm

So, Im plugging NA into cells that would otherwise be zero. I used this
code to fill down with NA in each column:

Range("B3").Select
Selection.AutoFill Destination:=Range _
(Selection, Selection.Offset(0, 1).End(xlDown).Offset(0, -1))

However, there are some cells towards the bottom of the list in B:E, before
the dates in Column A end. So, I get some zeros under the actual data! Im
trying to come up with a way of getting to the end of the used range in
Column A, offset 1 column, and select all cells from this current cell up to
B3, and fill all blanks with "=NA()". For instance, select B600:B3, and
enter =NA() into all blanks, knowing that the B600 changes constantly. Then,
move to Column C, D, and E. Does anyone have a good idea as to how to do
this?

Regards,
Ryan--


--
RyGuy