I have written vba code to hide columns when a range of cells do not match a specific initial. This piece of the code works. I want to expand the code with a message box to ask for input (Please enter initials?). Once initials entered run the below code based on the initials entered. Then ask Do you have additional initials? Based on that answer (Yes) either run the loop again or (No) stop the macro. This is my first time attempting to write code so thanks in advance for your help.
The loop should look at the initials entered, search the first cell and either hide the column or leave it open and then move to the next cell....etc...
Sub InputMessageMacroWithDo()
' this one works well to hide columns based on AS only currently using <> =
Dim rRange As Range
Dim rCell As Range
Dim ans As String
Dim myCheck As String
Dim initials As String
Set rRange = Sheets("Sheet1").Range("C25:<wbr>CK25").Cells
ans = MsgBox("Do you have Supervisor initials to enter?", vbYesNo)
If ans = vbNo Then Exit Sub
Do
initials = InputBox(Prompt:="Enter supervisor initials", title:="Supervisor Initials")
If UCase(rCell.Value) = initials Then rCell.Columns.EntireColumn.<wbr>Hidden = False
ans = MsgBox("Copy and paste the unhidden columns into a new tab. Label the tab with the Supervisors name. Do not press OK until you have completed the copy and paste. Once completed press OK.")
myCheck = MsgBox("Do you have more Supervisor initials to enter?", vbYesNo)
If myCheck = vbNo Then Exit Sub
Loop While myCheck = vbYes
End Sub
The loop should look at the initials entered, search the first cell and either hide the column or leave it open and then move to the next cell....etc...
Sub InputMessageMacroWithDo()
' this one works well to hide columns based on AS only currently using <> =
Dim rRange As Range
Dim rCell As Range
Dim ans As String
Dim myCheck As String
Dim initials As String
Set rRange = Sheets("Sheet1").Range("C25:<wbr>CK25").Cells
ans = MsgBox("Do you have Supervisor initials to enter?", vbYesNo)
If ans = vbNo Then Exit Sub
Do
initials = InputBox(Prompt:="Enter supervisor initials", title:="Supervisor Initials")
If UCase(rCell.Value) = initials Then rCell.Columns.EntireColumn.<wbr>Hidden = False
ans = MsgBox("Copy and paste the unhidden columns into a new tab. Label the tab with the Supervisors name. Do not press OK until you have completed the copy and paste. Once completed press OK.")
myCheck = MsgBox("Do you have more Supervisor initials to enter?", vbYesNo)
If myCheck = vbNo Then Exit Sub
Loop While myCheck = vbYes
End Sub