#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default MultiPage

Hi, i've got a multipage box with tabs that are labelled with years:-
2009;2010;2011.

I'm trying to hide those tabs that are greater than the current year, I've
started on the code below, but this hides all tabs, unless I change
'If .Pages(i).Caption Year(Now) Then' To
'If .Pages(i).Caption 2010'

With Me.MultiPage1
For i = 0 To .Count - 1
If .Pages(i).Caption Year(Now) Then
.Pages(i).Visible = False
End If
Next i

End With

Any ideas are welcome
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default MultiPage

I'm not sure what you mean by a multipage box, but I think I'd try changing
this

If .Pages(i).Caption Year(Now) Then

to

If .Pages(i).Caption format(date,"yyyy") Then
--
HTH,

Barb Reinhardt



"LaDdIe" wrote:

Hi, i've got a multipage box with tabs that are labelled with years:-
2009;2010;2011.

I'm trying to hide those tabs that are greater than the current year, I've
started on the code below, but this hides all tabs, unless I change
'If .Pages(i).Caption Year(Now) Then' To
'If .Pages(i).Caption 2010'

With Me.MultiPage1
For i = 0 To .Count - 1
If .Pages(i).Caption Year(Now) Then
.Pages(i).Visible = False
End If
Next i

End With

Any ideas are welcome

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default MultiPage

Thanks Barb, it did the trick.

"Barb Reinhardt" wrote:

I'm not sure what you mean by a multipage box, but I think I'd try changing
this

If .Pages(i).Caption Year(Now) Then

to

If .Pages(i).Caption format(date,"yyyy") Then
--
HTH,

Barb Reinhardt



"LaDdIe" wrote:

Hi, i've got a multipage box with tabs that are labelled with years:-
2009;2010;2011.

I'm trying to hide those tabs that are greater than the current year, I've
started on the code below, but this hides all tabs, unless I change
'If .Pages(i).Caption Year(Now) Then' To
'If .Pages(i).Caption 2010'

With Me.MultiPage1
For i = 0 To .Count - 1
If .Pages(i).Caption Year(Now) Then
.Pages(i).Visible = False
End If
Next i

End With

Any ideas are welcome

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default MultiPage

Hi,

The tab name is a string; not a numeric. Try the following.
Note that a space and underscore at the end of a line is a line break in an
otherwise single line of code.

Dim i As Long
With Me.MultiPage1
For i = 0 To .Count - 1
If .Pages(i).Caption _
Format(Year(Now), "0") Then

.Pages(i).Visible = False
End If
Next i

End With

--
Regards,

OssieMac


"LaDdIe" wrote:

Hi, i've got a multipage box with tabs that are labelled with years:-
2009;2010;2011.

I'm trying to hide those tabs that are greater than the current year, I've
started on the code below, but this hides all tabs, unless I change
'If .Pages(i).Caption Year(Now) Then' To
'If .Pages(i).Caption 2010'

With Me.MultiPage1
For i = 0 To .Count - 1
If .Pages(i).Caption Year(Now) Then
.Pages(i).Visible = False
End If
Next i

End With

Any ideas are welcome

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default MultiPage

Just for clarification, the constants Year(Now) equates to numeric and it
was being compared to text which is always greater than numeric. So your If
statement would be true in every case and therefor would hide each page.
The Format function that Barb suggested changes the year to text so that
apples are being compared to apples and it works.



"LaDdIe" wrote in message
...
Thanks Barb, it did the trick.

"Barb Reinhardt" wrote:

I'm not sure what you mean by a multipage box, but I think I'd try
changing
this

If .Pages(i).Caption Year(Now) Then

to

If .Pages(i).Caption format(date,"yyyy") Then
--
HTH,

Barb Reinhardt



"LaDdIe" wrote:

Hi, i've got a multipage box with tabs that are labelled with years:-
2009;2010;2011.

I'm trying to hide those tabs that are greater than the current year,
I've
started on the code below, but this hides all tabs, unless I change
'If .Pages(i).Caption Year(Now) Then' To
'If .Pages(i).Caption 2010'

With Me.MultiPage1
For i = 0 To .Count - 1
If .Pages(i).Caption Year(Now) Then
.Pages(i).Visible = False
End If
Next i

End With

Any ideas are welcome



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
Multipage?? TotallyConfused Excel Programming 1 November 3rd 09 06:17 AM
Multipage Name pjbur2005 via OfficeKB.com Excel Programming 2 September 14th 08 03:01 PM
multipage AManso Excel Programming 2 December 4th 07 03:06 PM
MultiPage tab JWM6[_5_] Excel Programming 4 April 22nd 06 02:06 AM
MultiPage Michael[_25_] Excel Programming 3 January 6th 04 12:49 PM


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