Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Count until condition is met and then retain final count

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Count until condition is met and then retain final count

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Count until condition is met and then retain final count

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
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
Count after given condition is met Antonio Excel Discussion (Misc queries) 7 May 15th 08 07:43 PM
Count cells with fill color and retain code - Mr. Umlas Can you he Counting Cells With Fill Color[_2_] Excel Discussion (Misc queries) 1 April 4th 08 12:58 AM
count between two date with one more condition count between two date with one more con Excel Worksheet Functions 1 April 19th 07 04:22 AM
count col-A if col-B = condition Balhar Excel Worksheet Functions 8 January 18th 06 09:52 PM
Count the occurence of more than one condition wutang1105 Excel Worksheet Functions 1 August 26th 05 07:21 PM


All times are GMT +1. The time now is 10:10 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"