S
Steph
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).Copy
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
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).Copy
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