Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Embarressing I thougth I knew the answer
My macro populates the cell if the relevant cell it is reading from (in another wb has data in it). If there is no data in it how do I put a 0 in that cell (C22)? Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
if range("c22").value = "" then 'it has no data
range("c22").value = 0 end if i think that's what you want. :) susan On Nov 13, 11:32*am, Lav wrote: Embarressing I thougth I knew the answer My macro populates the cell if the relevant cell it is reading from (in another wb has data in it). If there is no data in it how do I put a 0 in that cell (C22)? Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub zin()
If IsEmpty(Range("C22")) Then Range("C22").Value = 0 End If End Sub -- Gary''s Student - gsnu200813 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Nov 13, 8:32*am, Lav wrote:
Embarressing I thougth I knew the answer My macro populates the cell if the relevant cell it is reading from (in another wb has data in it). If there is no data in it how do I put a 0 in that cell (C22)? Thanks I like Gary's Student's IsEmpty method, but I probably would have used the cells(22,3) reference rather than range("c22") - that' probably just a personal pref, idk. Susan's suggestion of range("c22").value="" has failed me before. I've had more luck with =Empty than ="", not sure why actually. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
IsEmpty is nice because it finds TRUE empties rather than pseudo-empties.
Start with a new, fresh worksheet and in A1 enter: ="" If you now copy A1 and: Edit Paste Special Values into A2 and then run: Sub HowEmptyIsIt() For Each r In Range("A1:A3") MsgBox (r.Address & IsEmpty(r)) Next End Sub VBA will tell you that there is SOMETHING in A1 and A2. Same behavior as =COUNTA() and =ISBLANK() in the worksheet. -- Gary''s Student - gsnu200813 "jafsonic" wrote: On Nov 13, 8:32 am, Lav wrote: Embarressing I thougth I knew the answer My macro populates the cell if the relevant cell it is reading from (in another wb has data in it). If there is no data in it how do I put a 0 in that cell (C22)? Thanks I like Gary's Student's IsEmpty method, but I probably would have used the cells(22,3) reference rather than range("c22") - that' probably just a personal pref, idk. Susan's suggestion of range("c22").value="" has failed me before. I've had more luck with =Empty than ="", not sure why actually. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thanks for explaining that, i learned something new!
:) susan On Nov 13, 12:40*pm, Gary''s Student wrote: IsEmpty is nice because it finds TRUE empties rather than pseudo-empties. Start with a new, fresh worksheet and in A1 enter: ="" If you now copy A1 and: Edit Paste Special Values into A2 and then run: Sub HowEmptyIsIt() For Each r In Range("A1:A3") * * MsgBox (r.Address & IsEmpty(r)) Next End Sub VBA will tell you that there is SOMETHING in A1 and A2. Same behavior as =COUNTA() and =ISBLANK() in the worksheet. -- Gary''s Student - gsnu200813 "jafsonic" wrote: On Nov 13, 8:32 am, Lav wrote: Embarressing I thougth I knew the answer My macro populates the cell if the relevant cell it is reading from (in another wb has data in it). If there is no data in it how do I put a 0 in that cell (C22)? Thanks I like Gary's Student's IsEmpty method, but I probably would have used the cells(22,3) reference rather than range("c22") - that' probably just a personal pref, idk. Susan's suggestion of range("c22").value="" has failed me before. I've had more luck with =Empty than ="", not sure why actually.- Hide quoted text - - Show quoted text - |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Range("B2").AutoFill Destination:=Range("GX1", ActiveCell) ... Fails but why? | Excel Programming | |||
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" | Excel Programming | |||
Using "Cells" to write "Range("A:A,H:H").Select" | Excel Programming |