Date Functions (VB/EXCEL)

StefanRSA

New Member
Joined
May 26, 2008
Messages
24
Hi Guys,

I am trying to make the below code snippet work to return a date if all arguments are positive. Unfortunately, instead of returning the date, this function returns "". Is there something small I have missed out here?

Should I rather use .FormulaR1C1 = "=TODAY()"? Or is this because I have tried to do the Date function within a WITH statement.Interior? :confused:

'If rejected and resolved return todays date
If Left(Cells(ifindrow, iColNum(8) - 1).Value, 3) = "Rej" And Cells(ifindrow, iColNum(8)).Value = "Yes" Then
With Cells(ifindrow, iColNum(8) + 1).Interior
.ColorIndex = xlNone
.Value = Date
End With
End If

Many thanks for your consideration. ;)

Kind Regards,

Stefan
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

njimack

Well-known Member
Joined
Jun 17, 2005
Messages
7,772
You're trying to apply the date to the interior colour of the cell. Try this:


If Left(Cells(ifindrow, iColNum(8) - 1).Value, 3) = "Rej" And Cells(ifindrow, iColNum(8)).Value = "Yes" Then
With Cells(ifindrow, iColNum(8) + 1)
.Interior.ColorIndex = xlNone
.Value = Date
End With
End If
 
Upvote 0

StefanRSA

New Member
Joined
May 26, 2008
Messages
24
Thanks for the reply Neil, but I still have "" returned. Is there any other reason this should happen?

Im working with a document filled to the brim with code and it could very well be another macro overwriting this one to ""....
 
Upvote 0

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hello Stefan

If you are not getting the date in your cell(s) then it suggests the If test is returning False - check here first to make sure it is working as expected. Step thru the code using F8 so you can check the values of each cell
 
Upvote 0

StefanRSA

New Member
Joined
May 26, 2008
Messages
24
Hi Richard,

Thank you for this insight!

I think you may be right, perhaps if I specified an ELSE statement I would fix the FALSE return. I'll let you know how it goes...
 
Upvote 0

StefanRSA

New Member
Joined
May 26, 2008
Messages
24
Hi Richard,

I tried putting in the ELSE statement and that didnt seem to solve the problem. So I went through the surrounding code snippetts and it turns out one of the other statements further in was clearing that box. So the date was being printed, but then cleared by another function.

Thank you Rich and Neil for your help!! :)
 
Upvote 0

Forum statistics

Threads
1,191,537
Messages
5,987,166
Members
440,083
Latest member
Bluepanther

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top