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 / December 2006

Tip: Looking for answers? Try searching our database.

Cells: Any way to code an event behind one?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
(PeteCresswell) - 09 Dec 2006 16:50 GMT
I'm thinking I'd like to automatically select the next cell in a series after
the user pastes something into the current cell.

Can I write event code for a given cell, like "Cell(2,3).AfterUpdate()"?
Signature

PeteCresswell

Bob Phillips - 09 Dec 2006 17:15 GMT
It should be easy with a change event, but what does ... next cell in a
series ... mean?

Signature

---
HTH

Bob

(change the xxxx to gmail if mailing direct)

> I'm thinking I'd like to automatically select the next cell in a series
> after
> the user pastes something into the current cell.
>
> Can I write event code for a given cell, like "Cell(2,3).AfterUpdate()"?
(PeteCresswell) - 09 Dec 2006 20:28 GMT
Per Bob Phillips:
>It should be easy with a change event, but what does ... next cell in a
>series ... mean?

If I'm in R1C3, I'd want to move focus to R2C3.

How would the macro be named?

Or can it be any name and somehow associated with the cell via the UI?
Signature

PeteCresswell

Chip Pearson - 10 Dec 2006 18:28 GMT
Pete,

You need to use the Change event code. Right-click the appropriate sheet tab
and choose View Code. This will take you to that sheet's object module in
the VBA editor.  Paste in the following code:

Private Sub Worksheet_Change(ByVal Target As Range)
   '''''''''''''''''''''''''''''
   ' Restrict actions to A1:A10)
   '''''''''''''''''''''''''''''
   Dim ISect As Range
   Set ISect = Application.Intersect(Me.Range("A1:A10"), Target)
   If ISect Is Nothing Then
       Exit Sub
   Else
       If ISect.Cells.Count <> Target.Cells.Count Then
           Exit Sub
       End If
   End If
   Application.EnableEvents = False
   Target.Cells(Target.Cells.Count)(2, 1).Select
   Application.EnableEvents = True

End Sub

This code will select the cell below the paste operation after the paste. As
written, it will apply only to changes in the range A1:A10. Change that
range reference as appropriate.

Signature

Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

> Per Bob Phillips:
>>It should be easy with a change event, but what does ... next cell in a
[quoted text clipped - 5 lines]
>
> Or can it be any name and somehow associated with the cell via the UI?
(PeteCresswell) - 10 Dec 2006 19:47 GMT
Per Chip Pearson:
>You need to use the Change event code. Right-click the appropriate sheet tab
>and choose View Code. This will take you to that sheet's object module in
>the VBA editor.  Paste in the following code:
>
>Private Sub Worksheet_Change(ByVal Target As Range)
>    '''''''''''''''''''''''''''''

Thanks Chip.

The big revelation to Yours Truly was the concept of Worksheet_Change().
Signature

PeteCresswell

 
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.