restricted ws.list

KDS14589

Board Regular
Joined
Jan 10, 2019
Messages
182
Office Version
  1. 2016
Platform
  1. Windows
I'm using the following code to produce a list of worksheets in a workbook I'm working on, it lists the properties I'm interested in. I even got a Replacement Code further down the code to replace Visibility numbers with text., I'm trying to get a restricted list with the same results but for ws.codenames starting with "ShGE##", right now there are only 3 (ShGE01, ShGE02, ShGE03) but a lot is in the works.

List would populate: K4 = index (list will be K5:K200)

L4=name (list will be L5:L200)

M4=codename (list will be M5:M200)

N4=visibility (list will be N5:N200)

I would list my failures but not enough time or space (I even tried LIKE)

Any Help or suggestions would be appreciated.

VBA Code:
Const SwitchBoardName As String = "general.misc"
    Const FilterCell As String = "b5"
    Const OutputRow As Long = 5
    Const IndexClm As String = "c"
    Const NameClm As String = "d"
    Const VisibleClm As String = "h"
    Const CodeNameClm As String = "e"


    Dim Sb As Worksheet
    Dim Flt As String
    Dim TabNames() As String
    Dim r As Long
    Dim Ws As Worksheet
    Dim Rng As Range
    
    Set Sb = ThisWorkbook.Worksheets(SwitchBoardName)
    Flt = Sb.Range(FilterCell).Cells(1).Value
    ReDim TabNames(ThisWorkbook.Worksheets.Count)

    r = OutputRow
        [e4] = [{"Name"}]
        [f4] = [{"CodeName"}]
        [d4] = [{"Index"}]
        [g4] = [{"Visibility"}]
        
''''order by [index] accending by Fluff @ Mr Excell

    For Each Ws In ThisWorkbook.Worksheets
        If InStr(1, Ws.Name, Flt, vbTextCompare) = 1 Then
            Sb.Cells(r, NameClm).Resize(, 4).Value = Array(Ws.Index, Ws.Name, Ws.CodeName, Ws.Visible)
            r = r + 1
            End If
    Next Ws

    If r Then
        Set Rng = Sb.Range(Sb.Cells(OutputRow, NameClm), Sb.Cells(r - 1, NameClm))
        With Sb.Sort
            With .SortFields
                .Clear
                .Add Key:=Rng.Cells(1), _
                          SortOn:=xlSortOnValues, _
                          Order:=xlAscending, _
                          DataOption:=xlSortTextAsNumbers
            End With
            .SetRange Rng
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With

'''''General worksheets list'''''
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
I solved myself :)
VBA Code:
'''''General worksheets list'''''

    Const SwitchBoardNameG As String = "general.misc"
    Const FilterCellG As String = "J5"
    Const OutputRowG As Long = 6
    Const IndexClmG As String = "K"
    Const NameClmG As String = "L"
    Const VisibleClmG As String = "N"
    Const CodeNameClmG As String = "M"


    Dim SbG As Worksheet
    Dim FltG As String
    Dim TabNamesG() As String
    Dim rG As Long
    Dim WsG As Worksheet
    Dim RngG As Range
    
    
    Set SbG = ThisWorkbook.Worksheets(SwitchBoardNameG)
    FltG = SbG.Range(FilterCellG).Cells(1).Value
    ReDim TabNamesG(ThisWorkbook.Worksheets.Count)

    rG = OutputRow
        [L4] = [{"Name"}]
        [M4] = [{"CodeName"}]
        [K4] = [{"Index"}]
        [N4] = [{"Visibility"}]
        

    For Each WsG In ThisWorkbook.Worksheets
        If (WsG.CodeName Like "ShGE##") Then
        If InStr(1, WsG.Index, FltG, vbTextCompare) = 1 Then
            SbG.Cells(rG, IndexClmG).Resize(, 4).Value = Array(WsG.Index, WsG.Name, WsG.CodeName, WsG.Visible)
            rG = rG + 1
            End If
            End If
    Next WsG

    If rG Then
        Set RngG = SbG.Range(SbG.Cells(OutputRowG, IndexClmG), SbG.Cells(rG - 1, IndexClmG))
        With Sb.Sort
            With .SortFields
                .Clear
                .Add Key:=RngG.Cells(1), _
                          SortOn:=xlSortOnValues, _
                          Order:=xlDescending, _
                          DataOption:=xlSortTextAsNumbers
            End With
            .SetRange RngG
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    End If
 
Upvote 0
Solution

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top