0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ワークシート関連処理

Last updated at Posted at 2025-05-04

ワークシート名→ワークシート変換

指定したブックの中から指定したワークシート名のシートを返却する

'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' ワークシート関連処理
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' ワークシート名→ワークシート変換
'------------------------------------------------------------------------------
Public Function F_Excel_GetSheetName2Sheet( _
        ByRef aRtn As Worksheet, _
        ByVal aName As String, _
        Optional ByVal aBk As Workbook = Nothing) As Boolean
    Dim wkRet As Boolean
    Dim wkRtn As Worksheet
    
    Dim wkBk As Workbook: Set wkBk = aBk
    
    If aName = "" Then
        Exit Function
    End If
    
    If wkBk Is Nothing Then
        Set wkBk = ThisWorkbook
    End If
    
    For Each wkRtn In wkBk.Worksheets
        If wkRtn.Name Like aName Then
            wkRet = True
            Exit For
        End If
    Next wkRtn
    
    If wkRet = True Then
        Set aRtn = wkRtn
        F_Excel_GetSheetName2Sheet = True
    End If
End Function
Public Function F_Excel_ReturnSheetName2Sheet( _
        ByVal aName As String, _
        Optional ByVal aBk As Workbook = Nothing) As Worksheet
    F_Excel_GetSheetName2Sheet F_Excel_ReturnSheetName2Sheet, aName, aBk:=aBk
End Function

全表示

非表示、フィルタを解除し全セルを表示する

'------------------------------------------------------------------------------
' 全表示
'------------------------------------------------------------------------------
Public Sub S_Excel_ShowAll( _
        ByVal aSh As Worksheet)
    If aSh Is Nothing Then
        Exit Sub
    End If
    
    With aSh
        .Cells.Rows.Hidden = False
        .Cells.Columns.Hidden = False
        
        'オートフィルタが設定されている場合は全表示
        If .AutoFilterMode <> True Then
            'フィルタ設定無しの場合は無視
        ElseIf .FilterMode <> True Then
            '絞り込みされていない場合は虫
        Else
            .ShowAllData
        End If
    End With
End Sub
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?