Tell excel to skip part of a macro?

T

TimkenSteve

I am almost finished with a macro that reformats .csv into a report
then searches for a master log workbook and trasnfers and saves the
data. If the workbook cannot be found, I want excel to skip the cut and
paste part and simply save the workbook as "OrderStatus_All"

Any suggestions are greatly appriciated
Steve

'''''''''''''''''''''''''
'Transfer Data to Master'
'''''''''''''''''''''''''
'
'runs search for OrderStatus_All.xls'

Application.MoveAfterReturnDirection = xlDown
Application.MoveAfterReturn = True


Set fs = Application.FileSearch
With fs
.NewSearch
.LookIn = "c:\"
.SearchSubFolders = True
.MatchTextExactly = True
.Filename = "OrderStatus_All.xls"
If .Execute(msoSortByNone, msoSortOrderAscending, True) > 0 Then
End If

'counts the files in list and stores the value in total Count'

MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
totalcount = .FoundFiles.Count


R = Range("A2").End(xlDown).Row
Range("A3:p" & CStr(R)).Select
Selection.Copy

'finds and opens if not creates and saves to default folder for
user documents'
For i = 1 To .FoundFiles.Count
Workbooks.Open .FoundFiles(i)
Next i

ActiveSheet.Select
Columns("A:A").Select
Cells(Rows.Count, ActiveCell.Column).End(xlUp).Offset(1,
0).Select
ActiveSheet.Paste
Rows(Range("A65536").End(xlUp).Row).Delete


End With
 
P

paul.robinson

Hi
Your code doesn't seem to quite tally with what you want to do. You
seem to be looking for several workbooks in the code but only refer to
one in your question??

regards
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top