Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default RUN MACRO WHEN CELL IN COLUMN CHANGES VALUE

I am trying to run a macro when any cell in column 14 is less than or
equal to Today. Can anyone help?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default RUN MACRO WHEN CELL IN COLUMN CHANGES VALUE

On Apr 8, 2:06*pm, wrote:
I am trying to run a macro when any cell in column 14 is less than or
equal to Today. Can anyone help?


There are a bunch of different ways to do this but this is a really
basic macro that works.

You might want to associate it with a SelectionChange event as opposed
to a Change event because this macro will continually run every time
the worksheet is re-calculated and there is a date greater than today
in column 14.

- - - - - - - -

Private Sub Worksheet_Change(ByVal Target As Range)

For i = 1 To 65000
If IsDate(Cells(i, 14)) And Cells(i, 14) Now Then
MsgBox "Macro!"
Exit Sub
End If
Next i

End Sub

- - - - - - - -
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default RUN MACRO WHEN CELL IN COLUMN CHANGES VALUE

maybe

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("N:N")) Is Nothing Then
If IsDate(Target) And Target.Value <= Date Then
'do something
End If
End If
End Sub

worksheet code

Mike

" wrote:

I am trying to run a macro when any cell in column 14 is less than or
equal to Today. Can anyone help?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default RUN MACRO WHEN CELL IN COLUMN CHANGES VALUE

On Apr 8, 12:18*pm, "Brian B." wrote:
On Apr 8, 2:06*pm, wrote:

I am trying to run a macro when any cell in column 14 is less than or
equal to Today. Can anyone help?


There are a bunch of different ways to do this but this is a really
basic macro that works.

You might want to associate it with a SelectionChange event as opposed
to a Change event because this macro will continually run every time
the worksheet is re-calculated and there is a date greater than today
in column 14.

- - - - - - - -

Private Sub Worksheet_Change(ByVal Target As Range)

For i = 1 To 65000
If IsDate(Cells(i, 14)) And Cells(i, 14) Now Then
MsgBox "Macro!"
Exit Sub
End If
Next i

End Sub

- - - - - - - -


Thank you!

One more question - There could be a value of "Received" in the same
column and I do not want to the macro to run if that is the case. Can
I write that in?
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default RUN MACRO WHEN CELL IN COLUMN CHANGES VALUE

Thank you!

One more question - There could be a value of "Received" in the same
column and I do not want to the macro to run if that is the case. Can
I write that in?- Hide quoted text -

- Show quoted text -


Of course ... w/ Excel anything is possible (and there are normally
multiple way to do things)! :)

Overall I like Mike's code better than my previous post b/c it will
only trigger the macro when the date is actually entered (not when a
calculation occurs). Below is code where if "Received" appears as the
value of a cell in Column N the macro does not run. There is a bunch
more you can do where if the value of the cell to the left or right of
the cell is equal to "Received" then to not trigger the macro (but in
your post you said same column).

- - - - - - - - -

Private Sub Worksheet_Change(ByVal Target As Range)

Dim Txt As String
Dim x As Integer

Txt = "Received"

If Not Intersect(Target, Range("N:N")) Is Nothing Then

x = Application.WorksheetFunction.CountIf(Columns("N:N "), Txt)
If x 0 Then Exit Sub

If IsDate(Target) And Target.Value <= Now Then
'do something
MsgBox "Macro!"
'do something
End If
End If

End Sub

- - - - - - - - -

Below is code where if the cell in column M has "Received" the macro
does not run.

- - - - - - - - -

Private Sub Worksheet_Change(ByVal Target As Range)

Dim Txt As String
Txt = "Received"

If Not Intersect(Target, Range("N:N")) Is Nothing Then

If Target.Offset(0, -1).Value = Txt Then Exit Sub

If IsDate(Target) And Target.Value <= Now Then
'do something
MsgBox "Macro!"
'do something
End If
End If

End Sub


- - - - - - - - -

-Brian
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
MACRO HELP, PASTE CELL TO COLUMN Dan Excel Discussion (Misc queries) 0 February 3rd 10 06:34 PM
Macro to go to next blank cell in column RJB Excel Discussion (Misc queries) 3 February 28th 07 04:51 PM
Need the formula or macro. If i enter today date in the cell (Row 1,Column 2) and on tab out, the column 1 cell should be filled with "corresponding Day" of the date kakasay Excel Discussion (Misc queries) 1 January 22nd 07 12:31 PM
Need Formula or macro. If i enter today date in the cell (Row 1,Column 2) and on tab out, the column 1 cell should be filled with "corresponding Day" of the date kakasay Excel Discussion (Misc queries) 1 January 22nd 07 12:31 PM
Macro to go to last cell in a column excelnut1954 Excel Programming 3 December 19th 06 01:49 PM


All times are GMT +1. The time now is 07:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"