Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / April 2007

Tip: Looking for answers? Try searching our database.

Cell Change as a Trigger Macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kaken6@gmail.com - 30 Mar 2007 14:21 GMT
Hello all,
I posted my question in the programming board here:
http://groups.google.ca/group/microsoft.public.excel.programming/browse_thread/t
hread/11bada939dbf45c0/69530d8a32d69d85?lnk=st&q=kaken6&rnum=3&hl=en#69530d8a32d
69d85

but I’m not sure if it was the correct location nor gotten any
responses, so I hope this is alright!

Essentially, what I’m wanting to do seems similar to the question
here:
http://groups.google.ca/group/microsoft.public.excel.programming/browse_thread/t
hread/5031e29938183367/c00908a17e2edc07?lnk=st&q=excel+question+1+to+20+trigger&
rnum=1#c00908a17e2edc07


Norman Jones’ post seems to work for Neil, but I haven’t had such
luck.
What I’ve done (from the first link):

“This is what I have so far. It's all on the main module Right now
nothing is working.
I've decided to just check if the month has changed, it will serve my
purpose fine.
I named the cell containing the month "Month" and also the
subprogram.
------------------------------------------------
Sub Workbook_open()
   Dim NME As Name
   On Error Resume Next
   Set NME = ThisWorkbook.Names("Month") ‘I’m not sure what this
means, the workbook isn’t called month, its called Month Information
Form, or is this referencing the cell?
   If Err.Number <> 0 Then
       ThisWorkbook.Names.Add Name:="Month", _
                                           RefersTo:=" "
   End If
End Sub
Sub Month()
   Dim rng As Range
   Dim NME As Name
   Set rng = Range("C4") '<--- C4 contains the check cell which
(=Month)
   Set NME = ThisWorkbook.Names("Month")
   If rng.Value <> Evaluate(NME.RefersTo) Then
       NME.RefersTo = rng.Value
       Dim pt As PivotTable
       Dim ws As Worksheet
       Set ws = Worksheets("Sheet 1") '<-- name of one of the sheets
I want updated. What do I do for the others?
       Set pt = ws.PivotTable3 '<-- name of the pivot table when I
right click and go to properties
       pt.PivotCache.Refresh
   End If
End Sub
----------------------------------------------------
Then on the worksheets with the pivot tables I have
----------------------------------------------------
Public Sub Worksheet_Calculate()
   Call Month
End Sub
----------------------------------------------------
can you see anything wrong with what I'm doing? “

Many thanks!
Trevor Shuttleworth - 30 Mar 2007 19:14 GMT
Not sure what you mean by the "main module".  A WorkBook_Open event macro
needs to sit in the WorkBook Class Module ... the code page "behind" the
Workbook object.

Generally speaking, I would use a WorkSheet_Change event to monitor changes
to a cell.  This would sit in the WorkSheet Class module for the sheet where
the cell exists.

Regards

Trevor

Hello all,
I posted my question in the programming board here:
http://groups.google.ca/group/microsoft.public.excel.programming/browse_thread/t
hread/11bada939dbf45c0/69530d8a32d69d85?lnk=st&q=kaken6&rnum=3&hl=en#69530d8a32d
69d85

but I'm not sure if it was the correct location nor gotten any
responses, so I hope this is alright!

Essentially, what I'm wanting to do seems similar to the question
here:
http://groups.google.ca/group/microsoft.public.excel.programming/browse_thread/t
hread/5031e29938183367/c00908a17e2edc07?lnk=st&q=excel+question+1+to+20+trigger&
rnum=1#c00908a17e2edc07


Norman Jones' post seems to work for Neil, but I haven't had such
luck.
What I've done (from the first link):

"This is what I have so far. It's all on the main module Right now
nothing is working.
I've decided to just check if the month has changed, it will serve my
purpose fine.
I named the cell containing the month "Month" and also the
subprogram.
------------------------------------------------
Sub Workbook_open()
   Dim NME As Name
   On Error Resume Next
   Set NME = ThisWorkbook.Names("Month") '?I'm not sure what this
means, the workbook isn't called month, its called Month Information
Form, or is this referencing the cell?
   If Err.Number <> 0 Then
       ThisWorkbook.Names.Add Name:="Month", _
                                           RefersTo:=" "
   End If
End Sub
Sub Month()
   Dim rng As Range
   Dim NME As Name
   Set rng = Range("C4") '<--- C4 contains the check cell which
(=Month)
   Set NME = ThisWorkbook.Names("Month")
   If rng.Value <> Evaluate(NME.RefersTo) Then
       NME.RefersTo = rng.Value
       Dim pt As PivotTable
       Dim ws As Worksheet
       Set ws = Worksheets("Sheet 1") '<-- name of one of the sheets
I want updated. What do I do for the others?
       Set pt = ws.PivotTable3 '<-- name of the pivot table when I
right click and go to properties
       pt.PivotCache.Refresh
   End If
End Sub
----------------------------------------------------
Then on the worksheets with the pivot tables I have
----------------------------------------------------
Public Sub Worksheet_Calculate()
   Call Month
End Sub
----------------------------------------------------
can you see anything wrong with what I'm doing? "

Many thanks!
kaken6@gmail.com - 02 Apr 2007 14:34 GMT
On Mar 30, 2:14 pm, "Trevor Shuttleworth" <Tre...@Shucks.demon.co.uk>
wrote:
> Not sure what you mean by the "main module".  A WorkBook_Open event macro
> needs to sit in the WorkBook Class Module ... the code page "behind" the
[quoted text clipped - 68 lines]
>
> Many thanks!

Thanks Trevor,
I put the Workbook_Open event in a class module.
However, when I go to Sheet 1 I get an error saying that it can't find
my Pivot Table and highlights:
Set pt = ws.PivotTable3 (even though thats what its called when I go
to Table Options.
Could someone tell me if I am referencing my cells/sheets correctly?

Thanks

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.