T
Tsunami3169
Hello Everyone,
I'd like to thank everyone for their contribution to this group. I've
found many answers and direction to work out problems with my macros.
I'm always searcing this group before I post a question. This time one
of thoes times I'm unable to find an answer.
Here's the situation I have an input box that when the data entered is
false the box pops back up seeking more input. What I need is when the
loop is finished and there are no more sheets matching the data
entered I just need the box to close.
Here is the code.
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim sh As Variant
Dim WS As Excel.Worksheet
'Next section adjusts HTML pages saved from RI
'To run this selection on multi sheets a Wild Card can be used
Do Until sh = "False"
sh = Application.InputBox( _
Prompt:="Please enter name of Worksheet to be
formatted", _
Title:="Worksheet Name", _
Default:="*PO's", Type:=2)
If sh = "False" Then Exit Sub 'User Cancelled
For Each WS In Worksheets
If WS.Name Like sh Then WS.Select
Rows(2).Copy _
Destination:=Rows(1)
Rows(1).HorizontalAlignment = xlCenter
Rows(1).Select
Selection.Font.Bold = True
Rows("2:3").Delete
'Column Adjustments and Filter set
Columns("A:F").Select
Selection.EntireColumn.AutoFit
Selection.AutoFilter
Range("E:F").EntireColumn.Insert
Range("G:G").Select
Selection.NumberFormat = "#,#"
Range("H:H").Select
Selection.NumberFormat = "$#,#"
Else: End If
Next WS
Loop
Application.ScreenUpdating = True
End Sub
Many thanks for any help, advice and constructive criticism given, I'm
still learning VBA, so any help is appreciated.
I'd like to thank everyone for their contribution to this group. I've
found many answers and direction to work out problems with my macros.
I'm always searcing this group before I post a question. This time one
of thoes times I'm unable to find an answer.
Here's the situation I have an input box that when the data entered is
false the box pops back up seeking more input. What I need is when the
loop is finished and there are no more sheets matching the data
entered I just need the box to close.
Here is the code.
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim sh As Variant
Dim WS As Excel.Worksheet
'Next section adjusts HTML pages saved from RI
'To run this selection on multi sheets a Wild Card can be used
Do Until sh = "False"
sh = Application.InputBox( _
Prompt:="Please enter name of Worksheet to be
formatted", _
Title:="Worksheet Name", _
Default:="*PO's", Type:=2)
If sh = "False" Then Exit Sub 'User Cancelled
For Each WS In Worksheets
If WS.Name Like sh Then WS.Select
Rows(2).Copy _
Destination:=Rows(1)
Rows(1).HorizontalAlignment = xlCenter
Rows(1).Select
Selection.Font.Bold = True
Rows("2:3").Delete
'Column Adjustments and Filter set
Columns("A:F").Select
Selection.EntireColumn.AutoFit
Selection.AutoFilter
Range("E:F").EntireColumn.Insert
Range("G:G").Select
Selection.NumberFormat = "#,#"
Range("H:H").Select
Selection.NumberFormat = "$#,#"
Else: End If
Next WS
Loop
Application.ScreenUpdating = True
End Sub
Many thanks for any help, advice and constructive criticism given, I'm
still learning VBA, so any help is appreciated.