Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Selecting a specific tab in a tabstrip

Hello -
I have a tabstrip, and I have tabs added, the number depending on other
things. I need to make a specific tab (the last one, the one with the highest
index) the one that is selected. Right now, it shows the first tab (index =
0) and I can't figure out how to write code to default to the last one.
Can anyone help?

Thanks!
dan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Selecting a specific tab in a tabstrip


"Dan" wrote in message
...
Hello -
I have a tabstrip, and I have tabs added, the number depending on other
things. I need to make a specific tab (the last one, the one with the
highest
index) the one that is selected. Right now, it shows the first tab (index
=
0) and I can't figure out how to write code to default to the last one.



Sub SelectLastWorksheet()
'
Dim wkbMyWorkbook As Workbook
Dim shtMyWorksheet As Worksheet
Dim K As Integer
'
Set wkbMyWorkbook = ActiveWorkbook
K = wkbMyWorkbook.Worksheets.Count
Set shtMyWorksheet = wkbMyWorkbook.Worksheets(K)
shtMyWorksheet.Activate
End Sub

hth
Gys



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Selecting a specific tab in a tabstrip

On a userform?

Me.TabStrip1.Value = Me.TabStrip1.Tabs.Count - 1



Dan wrote:

Hello -
I have a tabstrip, and I have tabs added, the number depending on other
things. I need to make a specific tab (the last one, the one with the highest
index) the one that is selected. Right now, it shows the first tab (index =
0) and I can't figure out how to write code to default to the last one.
Can anyone help?

Thanks!
dan


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Selecting a specific tab in a tabstrip

Thanks Dave -
Yes, in a user form. Your suggestion works to bring that tab "forward". My
original question wasn't very clear. After that tab is "forward" or selected,
I expected it to run the "mytabstrip_Change()" event. But that is where I
can't seem to make it work.
Normally, the user clicks on a tab. This fires the _Change() event, and the
macro fills in the info for that tab.
So what I need is a way in the macro to select a "default" tab, after it
creates all of the tabs, and fill in the info for that tab.
I tried adding
Call mytabstrip_Change()
but that does NOT call the _Change() event. Why is that?

Thanks!
dan

"Dave Peterson" wrote:

On a userform?

Me.TabStrip1.Value = Me.TabStrip1.Tabs.Count - 1



Dan wrote:

Hello -
I have a tabstrip, and I have tabs added, the number depending on other
things. I need to make a specific tab (the last one, the one with the highest
index) the one that is selected. Right now, it shows the first tab (index =
0) and I can't figure out how to write code to default to the last one.
Can anyone help?

Thanks!
dan


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Selecting a specific tab in a tabstrip

It did fire the _change for me--well, if I wasn't on that last tab already.

If I was already there, then that tabstrip didn't change, so it didn't fire.

But if I wanted to call that _change routine, I could use:

Option Explicit
Private Sub CommandButton1_Click()
With Me.TabStrip1
If .Value = .Tabs.Count - 1 Then
'already on the last one, so call it direct
Call TabStrip1_Change
Else
'do nothing special, let excel do the work
.Value = .Tabs.Count - 1
End If
End With
End Sub
Private Sub TabStrip1_Change()
MsgBox Me.TabStrip1.Value
End Sub



Dan wrote:

Thanks Dave -
Yes, in a user form. Your suggestion works to bring that tab "forward". My
original question wasn't very clear. After that tab is "forward" or selected,
I expected it to run the "mytabstrip_Change()" event. But that is where I
can't seem to make it work.
Normally, the user clicks on a tab. This fires the _Change() event, and the
macro fills in the info for that tab.
So what I need is a way in the macro to select a "default" tab, after it
creates all of the tabs, and fill in the info for that tab.
I tried adding
Call mytabstrip_Change()
but that does NOT call the _Change() event. Why is that?

Thanks!
dan

"Dave Peterson" wrote:

On a userform?

Me.TabStrip1.Value = Me.TabStrip1.Tabs.Count - 1



Dan wrote:

Hello -
I have a tabstrip, and I have tabs added, the number depending on other
things. I need to make a specific tab (the last one, the one with the highest
index) the one that is selected. Right now, it shows the first tab (index =
0) and I can't figure out how to write code to default to the last one.
Can anyone help?

Thanks!
dan


--

Dave Peterson


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Selecting a specific tab in a tabstrip

Thanks again Dave -
You helped me find the problem - why doesn't mine fire when yours does????
I have a variable that my subs use in order to PREVENT other things from
firing when I don't want them to.
This variable was still set. So even calling the _Change event didn't do any
good, because the first thing the _Change sub does is check my variable, then
exit sub.
Jeez.

Thanks for the help!

dan

"Dave Peterson" wrote:

It did fire the _change for me--well, if I wasn't on that last tab already.

If I was already there, then that tabstrip didn't change, so it didn't fire.

But if I wanted to call that _change routine, I could use:

Option Explicit
Private Sub CommandButton1_Click()
With Me.TabStrip1
If .Value = .Tabs.Count - 1 Then
'already on the last one, so call it direct
Call TabStrip1_Change
Else
'do nothing special, let excel do the work
.Value = .Tabs.Count - 1
End If
End With
End Sub
Private Sub TabStrip1_Change()
MsgBox Me.TabStrip1.Value
End Sub



Dan wrote:

Thanks Dave -
Yes, in a user form. Your suggestion works to bring that tab "forward". My
original question wasn't very clear. After that tab is "forward" or selected,
I expected it to run the "mytabstrip_Change()" event. But that is where I
can't seem to make it work.
Normally, the user clicks on a tab. This fires the _Change() event, and the
macro fills in the info for that tab.
So what I need is a way in the macro to select a "default" tab, after it
creates all of the tabs, and fill in the info for that tab.
I tried adding
Call mytabstrip_Change()
but that does NOT call the _Change() event. Why is that?

Thanks!
dan

"Dave Peterson" wrote:

On a userform?

Me.TabStrip1.Value = Me.TabStrip1.Tabs.Count - 1



Dan wrote:

Hello -
I have a tabstrip, and I have tabs added, the number depending on other
things. I need to make a specific tab (the last one, the one with the highest
index) the one that is selected. Right now, it shows the first tab (index =
0) and I can't figure out how to write code to default to the last one.
Can anyone help?

Thanks!
dan

--

Dave Peterson


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Selecting a specific tab in a tabstrip

I don't know. Maybe one of us is special <bg.

I used xl2003 under winXP for my testing. You may want to start a new userform
(in a new workbook) to see if it fires there.

Dan wrote:

Thanks again Dave -
You helped me find the problem - why doesn't mine fire when yours does????
I have a variable that my subs use in order to PREVENT other things from
firing when I don't want them to.
This variable was still set. So even calling the _Change event didn't do any
good, because the first thing the _Change sub does is check my variable, then
exit sub.
Jeez.

Thanks for the help!

dan

"Dave Peterson" wrote:

It did fire the _change for me--well, if I wasn't on that last tab already.

If I was already there, then that tabstrip didn't change, so it didn't fire.

But if I wanted to call that _change routine, I could use:

Option Explicit
Private Sub CommandButton1_Click()
With Me.TabStrip1
If .Value = .Tabs.Count - 1 Then
'already on the last one, so call it direct
Call TabStrip1_Change
Else
'do nothing special, let excel do the work
.Value = .Tabs.Count - 1
End If
End With
End Sub
Private Sub TabStrip1_Change()
MsgBox Me.TabStrip1.Value
End Sub



Dan wrote:

Thanks Dave -
Yes, in a user form. Your suggestion works to bring that tab "forward". My
original question wasn't very clear. After that tab is "forward" or selected,
I expected it to run the "mytabstrip_Change()" event. But that is where I
can't seem to make it work.
Normally, the user clicks on a tab. This fires the _Change() event, and the
macro fills in the info for that tab.
So what I need is a way in the macro to select a "default" tab, after it
creates all of the tabs, and fill in the info for that tab.
I tried adding
Call mytabstrip_Change()
but that does NOT call the _Change() event. Why is that?

Thanks!
dan

"Dave Peterson" wrote:

On a userform?

Me.TabStrip1.Value = Me.TabStrip1.Tabs.Count - 1



Dan wrote:

Hello -
I have a tabstrip, and I have tabs added, the number depending on other
things. I need to make a specific tab (the last one, the one with the highest
index) the one that is selected. Right now, it shows the first tab (index =
0) and I can't figure out how to write code to default to the last one.
Can anyone help?

Thanks!
dan

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
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
Selecting data from a specific column Charp Excel Discussion (Misc queries) 1 December 8th 09 05:29 PM
Selecting a specific worksheet Jackie New Users to Excel 5 February 25th 09 07:03 PM
Selecting specific cells Michelle Excel Discussion (Misc queries) 1 March 12th 08 05:06 PM
Selecting Specific Sheets [email protected] Excel Programming 6 March 1st 07 04:12 PM
Specific Cell Selecting bodhisatvaofboogie Excel Programming 2 June 13th 06 07:04 PM


All times are GMT +1. The time now is 10:22 PM.

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"