ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check Work Books (https://www.excelbanter.com/excel-programming/441321-re-check-work-books.html)

Beep Beep

Check Work Books
 
Hi Gary

First off I want to apologize for listing this in two places. When I was
placing it I thought I was in the Excel Programming section but was only when
I went looking for replys that I discovered my error. I did not know if
people responding in the Excel section would see it. Sorry;

As far as your suggestion it runs, however I get a message box that says:
HAS 26 SHEETS AND CONTINUES TO LOOP UNTIL I HIT THE EXCAPE KEY.

Any suggestions?

"Gary''s Student" wrote:

Create a workbook and in column A put the filespecs:

C:\Temp\first.xls
C:\Temp\second.xls

basically a list of all the files you wish to check. Then run this:

Sub checkUm()
For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row
v = Cells(i, 1).Value
Workbooks.Open Filename:=v
n = ActiveWorkbook.Sheets.Count
If n 1 Then
MsgBox v & " has " & n & " sheets"
End If
ActiveWorkbook.Close
ThisWorkbook.Activate
Next
End Sub

B.T.W. this illustrates the difference between ActiveWorkbook and
ThisWorkbook.
--
Gary''s Student - gsnu201001


"Beep Beep" wrote:

I have around 100 Excel work books. In the original there are 3 worksheets.
I copy the one worksheet for each person into a new workbook in order to send
this to each individual.

What I would like to do is create a macro that I could run automatticaly
with all 100 individual workbooks to insure that there is only 1 worksheet on
these individual workbooks.

What I forsee is that I would have this macro in my personal workbook and
after opening all 100 workbooks then run the macro to check this workbooks.



All times are GMT +1. The time now is 12:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com