+ Reply to Thread
Results 1 to 3 of 3

selecting the last 5 sheets

Hybrid View

aishaz_88 selecting the last 5 sheets 12-11-2007, 04:49 AM
jindon try Sub test() Dim i As... 12-11-2007, 05:21 AM
aishaz_88 it worked 12-18-2007, 05:33 AM
  1. #1
    Registered User
    Join Date
    12-02-2007
    Posts
    27

    selecting the last 5 sheets

    Hi

    I need help again. I would like to know how do i select the last 5 sheets.

    for example I have sheet:

    1 2 3 4 5 6 7 8

    and i would like to only run a macro on the last 5 sheets.This macro is being run on a weekly basis. keeping in mind that the naming of the sheets may vary everytime i run the macro..so any help please?

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    try
    Sub test()
    Dim i As Integer, flg As Boolean
    If Sheets.Count > 4 Then
        For i = Sheets.Count - 4 To Sheets.Count
            If Not flg Then
                Sheets(i).Select
                flg = True
            Else
                Sheets(i).Select False
            End If
        Next
    End If
    End Sub

  3. #3
    Registered User
    Join Date
    12-02-2007
    Posts
    27

    Smile it worked

    Thanks your solution works great.

    Helped me a lot.
    I was busy with some other projects that i had really no time to come back to this project till now.

    Thank YOU!~

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1