PC Review


Reply
Thread Tools Rate Thread

Automatically starting macros

 
 
Shawn777
Guest
Posts: n/a
 
      4th Feb 2008
Can I get a macro to start once a cell range is changed?

I want to validate fixed input to a cell which will provide a dropdown menu
of selections to pick from. My question is can I get a marco to run once a
new selection is entered into the cell.
 
Reply With Quote
 
 
 
 
Jim Thomlinson
Guest
Posts: n/a
 
      4th Feb 2008
Right click on the sheet tab you want to react to the change and select view
code. Fust above the code window are 2 drop down menus. Change the one on the
left from General to Worksheet (A code stub will be added which we can delete
later). the drop down on the right now lists all of the events that you can
catch in a worksheet. Select the Change event and a code stub like this will
be added...

Private Sub Worksheet_Change(ByVal Target As Range)

End Sub

Target is a refence to the cell/s that have been changed so something like
this will catch a specific cell...

Private Sub Worksheet_Change(ByVal Target As Range)
if target.address = "$A$1" then msgbox target.value
End Sub
--
HTH...

Jim Thomlinson


"Shawn777" wrote:

> Can I get a macro to start once a cell range is changed?
>
> I want to validate fixed input to a cell which will provide a dropdown menu
> of selections to pick from. My question is can I get a marco to run once a
> new selection is entered into the cell.

 
Reply With Quote
 
Shawn777
Guest
Posts: n/a
 
      5th Feb 2008
Thank you, it took a few trys but I got it to work.

"Jim Thomlinson" wrote:

> Right click on the sheet tab you want to react to the change and select view
> code. Fust above the code window are 2 drop down menus. Change the one on the
> left from General to Worksheet (A code stub will be added which we can delete
> later). the drop down on the right now lists all of the events that you can
> catch in a worksheet. Select the Change event and a code stub like this will
> be added...
>
> Private Sub Worksheet_Change(ByVal Target As Range)
>
> End Sub
>
> Target is a refence to the cell/s that have been changed so something like
> this will catch a specific cell...
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> if target.address = "$A$1" then msgbox target.value
> End Sub
> --
> HTH...
>
> Jim Thomlinson
>
>
> "Shawn777" wrote:
>
> > Can I get a macro to start once a cell range is changed?
> >
> > I want to validate fixed input to a cell which will provide a dropdown menu
> > of selections to pick from. My question is can I get a marco to run once a
> > new selection is entered into the cell.

 
Reply With Quote
 
GordonT
Guest
Posts: n/a
 
      1st Sep 2009


"Shawn777" wrote:

> Thank you, it took a few trys but I got it to work.
>
> "Jim Thomlinson" wrote:
>
> > Right click on the sheet tab you want to react to the change and select view
> > code. Fust above the code window are 2 drop down menus. Change the one on the
> > left from General to Worksheet (A code stub will be added which we can delete
> > later). the drop down on the right now lists all of the events that you can
> > catch in a worksheet. Select the Change event and a code stub like this will
> > be added...
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> >
> > End Sub
> >
> > Target is a refence to the cell/s that have been changed so something like
> > this will catch a specific cell...
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > if target.address = "$A$1" then msgbox target.value
> > End Sub
> > --
> > HTH...
> >
> > Jim Thomlinson
> >
> >
> > "Shawn777" wrote:
> >
> > > Can I get a macro to start once a cell range is changed?
> > >
> > > I want to validate fixed input to a cell which will provide a dropdown menu
> > > of selections to pick from. My question is can I get a marco to run once a
> > > new selection is entered into the cell.


I also wanted a macro to run automatically, but when a particular worksheet
is opened. The Worksheet - Activate selection worked fine. Each time I now
open the worksheet the marco automatically updates its data analysis from
another worksheet. Great !
 
Reply With Quote
 
GordonT
Guest
Posts: n/a
 
      1st Sep 2009


"Shawn777" wrote:

> Can I get a macro to start once a cell range is changed?
>
> I want to validate fixed input to a cell which will provide a dropdown menu
> of selections to pick from. My question is can I get a marco to run once a
> new selection is entered into the cell.


See the other answers about Worksheet Change. It also works if you want a
macro to run when the sheet is activated. Choose Worksheet - Activate and put
your code there. I have it to automatically update an analysis of data from
another sheet.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Keys starting macros MSNewsGroup Windows XP General 1 26th Jun 2007 05:32 PM
Starting Over with Macros Uschi via AccessMonster.com Microsoft Access Macros 8 16th May 2007 02:28 AM
Starting/Stopping macros Nancy Microsoft Windows 2000 New Users 1 10th Sep 2003 03:02 AM
Macros - starting and stopping Nancy Microsoft Windows 2000 New Users 3 9th Sep 2003 07:26 PM
automatically running macros on starting up powerpoint 2000 mike Microsoft Powerpoint 1 3rd Sep 2003 07:32 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:30 PM.