LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Test if Sheet Exists - Tom Ogilvy

Hi Tom,

Remember last night you modified some code for me to include a message box
for files that did not contain the sheet "timesheet" (code below). Is it
possible to write the files that do not have that sheet to a log (maybe a
text file, or even the immediate window) as well as the message box? I was
hoping to add some code that would kick off this procedure automatically,
and didn't want the message box to hold up the procedure waiting for the ok
click.

Thanks in advance!


Sub OpenFiles_New()
'Opens Files in Folder

Dim GetFiles As Variant
Dim iFiles As Long
Dim nFiles As Long
Dim wkbk As Workbook
Dim sh As Worksheet

Application.ScreenUpdating = False
Application.DisplayAlerts = False
GetFiles = Application.GetOpenFilename _
(FileFilter:="Text Files (*.*),*.*", _
Title:="Select Timesheets to Include in SAP PO Upload",
MultiSelect:=True)
If TypeName(GetFiles) = "Boolean" Then
MsgBox "No Files Selected", vbOKOnly, "Nothing Selected"
End
Else
For iFiles = LBound(GetFiles) To UBound(GetFiles)
Workbooks.OpenText Filename:=GetFiles(iFiles)
Set wkbk = ActiveWorkbook

Set sh = Nothing
On Error Resume Next
Set sh = wkbk.Worksheets("TSData")
On Error Resume Next
If Not sh Is Nothing Then

' With ActiveWorkbook.Sheets("Timesheet").UsedRange
' .Value = .Value
' End With

wkbk.Sheets("TSData").Range("A10:AG" & _
Sheets("Timesheet").Range("A20").End(xlUp).Row).Co py
ThisWorkbook.Worksheets("Consol").Range("A" & _
Consol.Range("E65536").End(xlUp).Offset(1, 0).Row).PasteSpecial
_
Paste:=xlPasteValues
Else
MsgBox wkbk.Name & " does not have the TSData sheet"
End If
wkbk.Close
Next iFiles
End If

'**********************
'Duplicate Test Here

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Test if file exists Daniel Bonallack Excel Discussion (Misc queries) 2 May 4th 09 04:19 PM
Test for Worksheet Exists bcmiller[_8_] Excel Programming 4 July 2nd 04 11:46 AM
Test if folder exists, create if it doesn't? 43fan Excel Programming 1 March 1st 04 04:31 PM
Test if a folder exists, create if it doesn't? 43fan Excel Programming 3 March 1st 04 02:59 PM
Test if a folder exists Jeff Marshall Excel Programming 6 September 30th 03 05:21 PM


All times are GMT +1. The time now is 11:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"