Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to suppress "Select Sheet" alert?

Status
Not open for further replies.

feipezi

IS-IT--Management
Aug 10, 2006
316
US
Hi,
I set up a Excel macro to compare the sheets of the current Workbook with those of the previous book, to make sure the numbers on those sheets do not go too far apart.
However, if one of the tabs cannot be found in the Workbook, a square box will appear with a header of 'Select Sheet'. I have some 20 Workbooks and I don't want to click 'OK' or 'Cancel' 100 times to keep the process running.
I tried 'On Error Resume Next' and Application.DisplayAlerts=False but the box still keeps showing up.
Is there any way of keeping the box from showing up?
Here is a part of the macro (where the garb_tab not exist):

Sub Findout(RegionWorkbook As String)
'On Error Resume Next
Dim tabarray As Variant
RegionWorkbook_ = Replace(RegionWorkbook, "2008_08_", "2008_09_")
tabarray = Array("garb_tab", "garb_tab", "region_name", "region_name", "district_name", "district_name", _
"territory_name", "territory_name", "distpayerlist", "distpayerlist")
For i = LBound(tabarray) To UBound(tabarray) Step 2
j = i + 1
k = i + 2
Sheets("sheet" & j).Activate
ActiveSheet.UsedRange.ClearContents
GetValuesFromAClosedWorkbook "C:\jqzhang\tooltemp", RegionWorkbook, tabarray(i), "A1:A3000", "A1:A3000"
Call DeleteRows
ActiveSheet.Cells(Range("a1").CurrentRegion.Rows.Count, 1).Activate
Sheets("sheet" & k).Activate
ActiveSheet.UsedRange.ClearContents
GetValuesFromAClosedWorkbook "C:\jqzhang\tooltemp", RegionWorkbook_, tabarray(i), "A1:A3000", "A1:A3000"
Call DeleteRows
ActiveSheet.Cells(Range("a1").CurrentRegion.Rows.Count, 1).Activate
Next
On Error GoTo 0
End Sub

Sub CMTNSA()
Findout "Stl_An_Tool_2008_08_MHC.xls"
End Sub
 




Please use Process TGML tags for code and other emphasis.

If you do not know what that is, SEARCH this page for Process TGML

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I'm not sure if TGML tags have anything to do with the answers to the question.
thanks.
 

I am sure that they do not. But they make it easier to understand postings.

Try using a worksheet loop to compare your array..
Code:
dim ws as worksheet
for each ws in workbooks(RegionWorkbook)
   select case ws.name
     Case "garb_tab", "garb_tab", "region_name", "region_name", "district_name", "district_name", _
    "territory_name", "territory_name", "distpayerlist", "distpayerlist" 
       'got a hit--PROCEED
 
     Case else
       msgbox "No Match"
   end select
next


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
No, it's not going to work. Because you have to keep a workbook open to do what you suggested, which is the last thing I wanted to do since it will take forever to open and close 20 workbooks (each of the workbooks has the size of 30 to 50 MG).
This is why the function named 'GetValuesFromAClosedWorkBook'.
Thanks anyway.
 
Where did 'GetValuesFromAClosedWorkBook' come from? You never explain how this functions. A UDF, I suppose. So if you supply bad data, how does it respond? Not so well, it seems. I guess, because you never disclosed, that this statement is the one causing the problem, or somewhere in the UDF. Just GUESSING!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top