Thread: Date to nothing
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Date to nothing

Andy,

The problem is that you are using Selection , which is a range, as a row
number, which is a number. Change

strDate = Format(Cells(selection, "A"), "dd/mm/yyyy")

to

strDate = Format(Cells(Selection.Row, "A"), "dd/mm/yyyy")


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"andyathome " wrote in message
...
Seeing another post, I noticed that you can format dates from cells:

i.e.

strDate = Format(Cells(selection, "A"), "dd/mm/yyyy")

That sounds idea for what I need. However, I guess I need to set the
variable strDate to a Date.

i.e.

Dim strDate as Date

That is great. But what I need to do is also have a condition that sets
the strDate variable to nothing if a condition is true

i.e.

If strCondition = "1" then

strDate = Format(Cells(selection, "A"), "dd/mm/yyyy")

Else

strDate = ""

End if

When I tried this, it said Type Mismatch. Obviously I need to wipe the
old date out from the variable stDate everytime I loop through. Is
there a way to set a date to nothing?

Any help is appreciated.


---
Message posted from http://www.ExcelForum.com/