|
はじめまして
ページ毎に役職入れて、1行に1人入れると下のマクロが人数分必要になってしまいます。
もっと簡単に役職が変わっても大丈夫な様なマクロはないでしょうか?
Sub チェックA()
With Sheets("氏名一覧")
If .[M4] = "役職A" Then
A役職A
ElseIf .[M4] = "掃除" Then
A掃除
ElseIf .[M4] = "役職B" Then
A役職B
ElseIf .[M4] = "役職C" Then
A役職C
ElseIf .[M4] = "役職D" Then
A役職D
ElseIf .[M4] = "学生" Then
A学生
ElseIf .[M4] = "社長" Then
A社長
ElseIf .[M4] = "役員" Then
A役員
ElseIf .[M4] = "監事" Then
A監事
ElseIf .[M4] = "事務" Then
A事務
Else
A0
End If
End With
End Sub
Sub A0()
Sheets("役職A").Select
Rows("4:4").Select
Selection.EntireRow.Hidden = True '役職A
Range("A1").Select
Sheets("一般").Select
Rows("4:4").Select
Selection.EntireRow.Hidden = True
Range("A1").Select
Sheets("役職B").Select
Rows("4:4").Select
Selection.EntireRow.Hidden = True
Range("A1").Select
Sheets("掃除").Select
Rows("4:4").Select
Selection.EntireRow.Hidden = True
Range("A1").Select
Sheets("役職C").Select
Rows("4:4").Select
Selection.EntireRow.Hidden = True
Range("A1").Select
Sheets("役職D").Select
Rows("4:4").Select
Selection.EntireRow.Hidden = True
Range("A1").Select
Sheets("学生").Select
Rows("4:4").Select
Selection.EntireRow.Hidden = True
Range("A1").Select
Sheets("役員").Select
Rows("4:4").Select
Selection.EntireRow.Hidden = True '社長
Rows("104:104").Select
Selection.EntireRow.Hidden = True '役員
Rows("204:204").Select
Selection.EntireRow.Hidden = True '監事
Range("A1").Select
Sheets("氏名一覧").Select
Range("A4").Select
End Sub
Sub A役職A()
Sheets("一般").Select
Rows("4:4").Select
Selection.EntireRow.Hidden = False
Range("A1").Select
Sheets("役職A").Select
Rows("4:4").Select
Selection.EntireRow.Hidden = False
Range("A1").Select
Sheets("役職B").Select
Rows("4:4").Select
Selection.EntireRow.Hidden = True
Range("A1").Select
Sheets("掃除").Select
Rows("4:4").Select
Selection.EntireRow.Hidden = True
Range("A1").Select
Sheets("役職C").Select
Rows("4:4").Select
Selection.EntireRow.Hidden = True
Range("A1").Select
Sheets("役職D").Select
Rows("4:4").Select
Selection.EntireRow.Hidden = True
Range("A1").Select
Sheets("学生").Select
Rows("4:4").Select
Selection.EntireRow.Hidden = True
Range("A1").Select
Sheets("役員").Select
Rows("4:4").Select
Selection.EntireRow.Hidden = True
Rows("104:104").Select
Selection.EntireRow.Hidden = True '役員
Rows("204:204").Select
Selection.EntireRow.Hidden = True '監事
Range("A1").Select
Sheets("氏名一覧").Select
Range("A4").Select
End Sub
・
・
・
|
|