Public Sub 隐藏B()
'
' 隐藏B Macro
' 宏由 Administrator 录制,时间: 2022/05/14
'
Dim total As Integer ' 整型变量,存放总行数
Dim counter As Integer ' 整型变量,for循环变量,每循环一次该值加1
Dim st$ ' 字符串变量,存放每个sheet页名字
Range("A1").CurrentRegion.Select '遍历当前整个sheet页
total = Selection.Rows.Count ' 得到总行数,作为循环终止
For counter = 2 To total ' 从第二行开始到最后一行循环
st = Cells(counter, 1) ' 读取sheet页中的第counter行第1列的值,保存为字符串形式。读出的字符串是每个sheet页的名字
If (Cells(counter, 2) = "B") Then ' Cells(counter, 2)表示第counter行第2列
Sheets(st).Visible = False
ElseIf Cells(counter, 2) = "A" Then ' Cells(counter, 2)表示第counter行第2列
Sheets(st).Visible = True
Sheets("目录").Activate
End If
Next counter
End Sub ' 隐藏B程序结束