# Help with Function Procedure?

#### Lalo2DaG

##### New Member
I download a report every day. This report tells me how olda certain product will be by a future date. For my purposes, I have to then adda column and do a quick calculation. My calculation is as follows: Future date –Todays date = number of days. <o></o>
For example, the product future date is 10/1/2017 and todaysdate is 11/30/2016. 10/1/2017 – 11/30/2016= 305 days.<o></o>
I have been trying to find a way to write code to do thisfor me, preferably without having to add an extra column. I think it should be a functionprocedure. The column on the excel sheetis “AF”. I hope I made my question clearand not overly confusing. But any help would be greatly appreciated. Thank you.<o></o>

### Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

#### BQardi

##### Active Member
If you don't want an extra column, how would you like this information to be presented to you?

#### Lalo2DaG

##### New Member
Preferably if the existing column is overwritten.

#### BQardi

##### Active Member
something like this:
Code:
``````Sub NumDaysToFutureDate()
Dim rng As Range, cell As Range, FutureDate As Variant
Application.ScreenUpdating = False
Set rng = Range("AF1", Cells(Rows.Count, "AF").End(xlUp))
For Each cell In rng
On Error Resume Next
FutureDate = CDate(cell.Value)
On Error GoTo 0
If FutureDate > Date And VarType(FutureDate) = vbDate Then cell.Value = FutureDate - Date
Next cell
rng.NumberFormat = "0"
End Sub``````

Replies
0
Views
234
Replies
4
Views
154
Replies
0
Views
447
Replies
11
Views
228
Replies
3
Views
240

1,190,916
Messages
5,983,567
Members
439,849
Latest member
Tlaw

### 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?

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