Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Lav Lav is offline
external usenet poster
 
Posts: 8
Default If Range ("C22") < = 0

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default If Range ("C22") < = 0

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default If Range ("C22") < = 0

Sub zin()
If IsEmpty(Range("C22")) Then
Range("C22").Value = 0
End If
End Sub
--
Gary''s Student - gsnu200813
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default If Range ("C22") < = 0

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default If Range ("C22") < = 0

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default If Range ("C22") < = 0

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
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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Range("B2").AutoFill Destination:=Range("GX1", ActiveCell) ... Fails but why? [email protected] Excel Programming 0 March 13th 07 02:22 AM
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" Luc[_3_] Excel Programming 2 September 28th 05 08:37 PM
Using "Cells" to write "Range("A:A,H:H").Select" Trip Ives[_2_] Excel Programming 3 June 5th 04 03:13 PM


All times are GMT +1. The time now is 03:08 AM.

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"