Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default worksheet selection count

hi,
i need to write a subroutine that will count the number of times a worksheet
is selected. so everytime the worksheet is selected i need to add one to the
value in Cell A1... the only line of code i was given is...

range("A1")=range("A1")+1
can anyone help???
thanx

--
"The difference between Possible and Impossible is the measure of ones will"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default worksheet selection count

Private Sub Worksheet_Activate()
With Activesheet.Range("A1")
.Value = .Value + 1
End With
End Sub

This is worksheet event code, which means that it needs to be
placed in the appropriate worksheet code module, not a standard
code module. To do this, right-click on the sheet tab, select
the View Code option from the menu, and paste the code in.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Kelzina" wrote in message
...
hi,
i need to write a subroutine that will count the number of times a

worksheet
is selected. so everytime the worksheet is selected i need to add one to

the
value in Cell A1... the only line of code i was given is...

range("A1")=range("A1")+1
can anyone help???
thanx

--
"The difference between Possible and Impossible is the measure of ones

will"


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default worksheet selection count

Hi Kelzina,

Your code is correct - you just need to put it in the Worksheet_Activate bit
for the worksheet you are interested in.

Go to the VB Environment (Alt + F11) and double click your worksheet in the
Project Explorer. Select "Worksheet" in the left hand drop down box. Select
"Activate" in the right hand drop down box. Enter your code in the Sub it
creates.

You should end up with something like this:

Private Sub Worksheet_Activate()
Range("A1") = Range("A1") + 1
End Sub

hth
big t


"Kelzina" wrote:

hi,
i need to write a subroutine that will count the number of times a worksheet
is selected. so everytime the worksheet is selected i need to add one to the
value in Cell A1... the only line of code i was given is...

range("A1")=range("A1")+1
can anyone help???
thanx

--
"The difference between Possible and Impossible is the measure of ones will"

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default worksheet selection count

In worksheet code:

Private Sub Worksheet_Activate()
Range("A1").Value = Range("A1").Value + 1
End Sub

REMEMBER: worksheet code
--
Gary's Student


"Kelzina" wrote:

hi,
i need to write a subroutine that will count the number of times a worksheet
is selected. so everytime the worksheet is selected i need to add one to the
value in Cell A1... the only line of code i was given is...

range("A1")=range("A1")+1
can anyone help???
thanx

--
"The difference between Possible and Impossible is the measure of ones will"

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
Lock worksheet, based on dropdown selection prior worksheet Michele New Users to Excel 9 June 21st 09 10:31 PM
count based on selection from drop down list lovejunkie02 Excel Worksheet Functions 2 September 21st 07 10:04 PM
No cell-selection in worksheet Gert-Jan Excel Programming 2 June 25th 06 11:29 AM
Worksheet Selection Gazza Excel Programming 3 May 5th 05 05:45 PM
Selection.count isnt working No Name Excel Programming 2 February 8th 04 03:23 PM


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