![]() |
Input box doesn't close if input is false
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. |
Input box doesn't close if input is false
Remove the quotes around False
Since you're exiting the sub if the user cancels, there's no need for the Until sh = ... after Do, either. In article . com, Tsunami3169 wrote: If sh = "False" Then Exit Sub 'User Cancelled |
Input box doesn't close if input is false
On May 8, 10:23 am, JE McGimpsey wrote:
Remove the quotes around False Since you're exiting the sub if the user cancels, there's no need for the Until sh = ... after Do, either. In article . com, Tsunami3169 wrote: If sh = "False" Then Exit Sub 'User Cancelled- Hide quoted text - - Show quoted text - Thanks tons. It works perfect now. |
All times are GMT +1. The time now is 12:04 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com