Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Appreciate if some sharp individual can assist me with the following issue.
In cell A1 I have a date. In cell B1 I have a number between 1 and 100. I need a formula in C1 to count the number of days between today and the date in A1 until the number in A2 = 100. However, Once A2 = 100 I need the formula in C1 to retain the final number of days counted. -- Cheers Ant. |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
You will have to use a VBA solution to acheive this. Select the sheet tab
which you want to work with. Right click the sheet tab and click on 'View Code'. This will launch VBE. Paste the below code to the right blank portion. Get back to to workbook and try out. Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Range("A2").Value = 100 Then Range("C1") = Date - Range("A1") Else Range("C1").Formula = "=TODAY()-A1" End If Application.EnableEvents = True End Sub -- Jacob "Fats" wrote: Appreciate if some sharp individual can assist me with the following issue. In cell A1 I have a date. In cell B1 I have a number between 1 and 100. I need a formula in C1 to count the number of days between today and the date in A1 until the number in A2 = 100. However, Once A2 = 100 I need the formula in C1 to retain the final number of days counted. -- Cheers Ant. |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi Jacob,
The macro is doing exactly what I requested. Nice one. Excuse my lack of VB knowledge but I am trying to enlargen the range of this macro but am struggling to make it work. See below. Appreciate your steer on this. Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Range("E3:E10").Value = 100 Then Range("G3:G10") = Date - Range("D3:D10") Else Range("G3:G10").Formula = "=TODAY() - Range("D3:D10")" End If Application.EnableEvents = True End Sub -- Cheers Ant. "Jacob Skaria" wrote: You will have to use a VBA solution to acheive this. Select the sheet tab which you want to work with. Right click the sheet tab and click on 'View Code'. This will launch VBE. Paste the below code to the right blank portion. Get back to to workbook and try out. Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Range("A2").Value = 100 Then Range("C1") = Date - Range("A1") Else Range("C1").Formula = "=TODAY()-A1" End If Application.EnableEvents = True End Sub -- Jacob "Fats" wrote: Appreciate if some sharp individual can assist me with the following issue. In cell A1 I have a date. In cell B1 I have a number between 1 and 100. I need a formula in C1 to count the number of days between today and the date in A1 until the number in A2 = 100. However, Once A2 = 100 I need the formula in C1 to retain the final number of days counted. -- Cheers Ant. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Count after given condition is met | Excel Discussion (Misc queries) | |||
Count cells with fill color and retain code - Mr. Umlas Can you he | Excel Discussion (Misc queries) | |||
count between two date with one more condition | Excel Worksheet Functions | |||
count col-A if col-B = condition | Excel Worksheet Functions | |||
Count the occurence of more than one condition | Excel Worksheet Functions |