Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Detecting Selected WorkSheet

I would like to write a macro by depending on the user SELECTED
worksheet to work on something.

Is it possible to detect (know) which page or pages are selected by the
user? please

Thank a lot!!



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Detecting Selected WorkSheet

strWs = ActiveSheet.Name

Select Case strWs
Case "Red": ' Do this
Case "Blue": ' Do that
Case "Yellow":' Do the other.
Case Else: ' Do something else.
End Select

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------
I would like to write a macro by depending on the user SELECTED
worksheet to work on something.

Is it possible to detect (know) which page or pages are selected by the
user? please

Thank a lot!!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Detecting Selected WorkSheet

Private Sub Worksheet_Activate()
x = ActiveSheet.Name
i = 2
Do
If Sheets("Summary").Cells(i, 1) = "" Then
Sheets("Summary").Cells(i, 1) = Application.UserName
Sheets("Summary").Cells(i, 2) = x
Sheets("Summary").Cells(i, 3) = Now()
GoTo ext
Else
i = i + 1
End If
Loop
ext:
End Sub


you create a sheet, name= Summary
A column User name
B column sheet name which is using by user
C column Date


-----Original Message-----
I would like to write a macro by depending on the user

SELECTED
worksheet to work on something.

Is it possible to detect (know) which page or pages are

selected by the
user? please

Thank a lot!!



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Detecting Selected WorkSheet

write this code in all worksheet

-----Original Message-----
Private Sub Worksheet_Activate()
x = ActiveSheet.Name
i = 2
Do
If Sheets("Summary").Cells(i, 1) = "" Then
Sheets("Summary").Cells(i, 1) = Application.UserName
Sheets("Summary").Cells(i, 2) = x
Sheets("Summary").Cells(i, 3) = Now()
GoTo ext
Else
i = i + 1
End If
Loop
ext:
End Sub


you create a sheet, name= Summary
A column User name
B column sheet name which is using by user
C column Date


-----Original Message-----
I would like to write a macro by depending on the user

SELECTED
worksheet to work on something.

Is it possible to detect (know) which page or pages are

selected by the
user? please

Thank a lot!!



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/

.

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Detecting Selected WorkSheet

No .. you mis-understand my meaning ..

in Excel you can select multiple worksheet by click the tab with shift
button (Sheet1, Sheet2, Sheet3, etc) and then apply function on them.

Now I would like to write a macro, which effect to the user's selected
worksheet. It is a dynamical situation.

Got it ??

:)



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Detecting Selected WorkSheet

VBA doesn't really support what you describe. Some of this functionality
can be achieved by using the selection object, but it is more robust to loop
through the sheets and make the change on each sheet

for each sh in ActiveWindow.Selectedsheets
' add code to do the work such as:
sh.Range("A1").Interior.ColorIndex = 3
Next

--
Regards,
Tom Ogilvy

"LeoNgan" wrote in message
...
No .. you mis-understand my meaning ..

in Excel you can select multiple worksheet by click the tab with shift
button (Sheet1, Sheet2, Sheet3, etc) and then apply function on them.

Now I would like to write a macro, which effect to the user's selected
worksheet. It is a dynamical situation.

Got it ??

:)



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Detecting Selected WorkSheet

No .. you mis-understand my meaning ..

in Excel you can select multiple worksheet by click the tab with shift
button (Sheet1, Sheet2, Sheet3, etc) and then apply function on them.

Now I would like to write a macro, which effect to the user's selected
worksheet. It is a dynamical situation.

Got it ??

:)



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Detecting Selected WorkSheet

No, you mis-understand. Excel VBA doesn't support this. I described a
workaround.

Got-it

--
Regards,
Tom Ogilvy

LeoNgan wrote in message
...
No .. you mis-understand my meaning ..

in Excel you can select multiple worksheet by click the tab with shift
button (Sheet1, Sheet2, Sheet3, etc) and then apply function on them.

Now I would like to write a macro, which effect to the user's selected
worksheet. It is a dynamical situation.

Got it ??

:)



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Detecting Selected WorkSheet

Anyway, all kidding aside, the problem you describe can be done using the
selection object as I originally stated:

Sub Tester2()
Dim shts As Sheets
Dim sh As Worksheet
Set shts = Worksheets(Array("Sheet1", "Sheet2", "Sheet3"))
Set sh = ActiveSheet
shts.Select
Range("A1").Select
Selection.Formula = "=Sum(C1:C30)"
sh.Select

End Sub

but also, in general, grouping sheets in vba (as above) is not supported.

--
Regards,
Tom Ogilvy

Tom Ogilvy wrote in message
...
No, you mis-understand. Excel VBA doesn't support this. I described a
workaround.

Got-it

--
Regards,
Tom Ogilvy

LeoNgan wrote in message
...
No .. you mis-understand my meaning ..

in Excel you can select multiple worksheet by click the tab with shift
button (Sheet1, Sheet2, Sheet3, etc) and then apply function on them.

Now I would like to write a macro, which effect to the user's selected
worksheet. It is a dynamical situation.

Got it ??

:)



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/





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
Blocking/Disabling selected worksheet DJ Ghale Excel Worksheet Functions 1 September 16th 08 01:19 AM
Detecting Duplicate Sums - Worksheet code [email protected] Excel Discussion (Misc queries) 0 September 27th 07 02:20 AM
Hiding worksheet unless selected SAP PoD Excel Discussion (Misc queries) 2 August 18th 06 03:45 PM
How to run a macro when a worksheet is selected cpmittal Excel Worksheet Functions 2 July 27th 05 11:57 AM
Detecting Worksheet change Tim[_14_] Excel Programming 2 July 10th 03 01:47 PM


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