Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default If a cell value is today's date, than increace cell value by one

Hi, I would like to compare a columns that contains date (2005/11/30)
to today's date.
If it is, than increase a cell by one.
I'm having problem with the format

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Columns("A1:A10")) Is Null Then
;so it skips the empty cells
Application.EnableEvents = False
if the cell is today's date than ;not sure
of the format
Range("A1").Value = Range("A1").Value + 1
Application.EnableEvents = True
End If
End Sub

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default If a cell value is today's date, than increace cell value by one


"magickarle" escribió en el mensaje
oups.com...
Hi, I would like to compare a columns that contains date (2005/11/30)
to today's date.
If it is, than increase a cell by one.
I'm having problem with the format

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Columns("A1:A10")) Is Null Then
;so it skips the empty cells
Application.EnableEvents = False
if the cell is today's date than ;not sure
of the format
Range("A1").Value = Range("A1").Value + 1
Application.EnableEvents = True
End If
End Sub

Thanks



Try this:

If [D1] = Date Then

supossing D1 contains the date to compare...


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default If a cell value is today's date, than increace cell value by one

Ok but how can I loop the
If D1 = Date then...

I would like to do a loop between A1 n A10
Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default If a cell value is today's date, than increace cell value by one

For column = 1 to 10
if Range ("A" & column).Value = Date Then
'Your actions here
End If
Next Column

Or if you want to compare from A1 to F1

For letter= 65 to 70 'Ascii values of letters A to F
if Range (chr(letter) & "1").Value = Date Then
'Your actions here
End If
Next letter

"magickarle" escribió en el mensaje
oups.com...
Ok but how can I loop the
If D1 = Date then...

I would like to do a loop between A1 n A10
Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default If a cell value is today's date, than increace cell value by one

cool. I didn't think of using ascii value (I did it when I was doing
Ada script. I guess it's the same principle as other script language)

Another question: I would like to compare two columns
Ex: @ an event on column F do
If column F = 1 and Column G got nothing do
Increase F341 by one
If column F = 2 and Column G got nothing do
Increase F342 by one
If column F = 3 and Column G got nothing do
Increase F343 by one
End if.a
What I did is:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Columns("F:F")) Is Nothing Then
Application.EnableEvents = False
If Application.Intersect(Target, Columns("F:F")) Is "1" And
Application.Intersect(Target, Columns("G:G")) Is Nothing Then
Range("F341").Value = Range("F341").Value + 1
If Application.Intersect(Target, Columns("F:F")) Is "2" And
Application.Intersect(Target, Columns("G:G")) Is Nothing Then
Range("F342").Value = Range("F342").Value + 1
If Application.Intersect(Target, Columns("F:F")) Is "3" And
Application.Intersect(Target, Columns("G:G")) Is Nothing Then
Range("F343").Value = Range("F343").Value + 1
End If
End If
End Sub

It gives me an error "type not compatible" for the Is "1" in the first
if.
I guess it's bcause I choose Private Sub Worksheet_Change(ByVal Target
As Range)

thanks again for your help.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default If a cell value is today's date, than increace cell value by one

Do not say Is "1"

Say = "1" or =1 (depends on if your are handling text or numbers

"magickarle" escribió en el mensaje
oups.com...
cool. I didn't think of using ascii value (I did it when I was doing
Ada script. I guess it's the same principle as other script language)

Another question: I would like to compare two columns
Ex: @ an event on column F do
If column F = 1 and Column G got nothing do
Increase F341 by one
If column F = 2 and Column G got nothing do
Increase F342 by one
If column F = 3 and Column G got nothing do
Increase F343 by one
End if.a
What I did is:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Columns("F:F")) Is Nothing Then
Application.EnableEvents = False
If Application.Intersect(Target, Columns("F:F")) Is "1" And
Application.Intersect(Target, Columns("G:G")) Is Nothing Then
Range("F341").Value = Range("F341").Value + 1
If Application.Intersect(Target, Columns("F:F")) Is "2" And
Application.Intersect(Target, Columns("G:G")) Is Nothing Then
Range("F342").Value = Range("F342").Value + 1
If Application.Intersect(Target, Columns("F:F")) Is "3" And
Application.Intersect(Target, Columns("G:G")) Is Nothing Then
Range("F343").Value = Range("F343").Value + 1
End If
End If
End Sub

It gives me an error "type not compatible" for the Is "1" in the first
if.
I guess it's bcause I choose Private Sub Worksheet_Change(ByVal Target
As Range)

thanks again for your help.



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
If cell is blank automatically enter today's date in the same cell LCTECH001 Excel Discussion (Misc queries) 22 April 5th 23 02:50 PM
conditional formatting for cell date to equal today's date Sistereinstein Excel Worksheet Functions 2 September 10th 12 07:53 PM
date in Cell to change colors if the date is beyond today's date Pete Elbert Excel Discussion (Misc queries) 2 June 6th 09 06:31 AM
Referencing Cell Next To Today's Date Cell Docktondad Excel Discussion (Misc queries) 5 May 16th 07 10:25 PM
text and today's date in 1 cell rexie3 Excel Discussion (Misc queries) 5 February 8th 07 10:38 PM


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