SuperFerret
Well-known Member
- Joined
- Mar 2, 2009
- Messages
- 515
Hi All,
I am trying to amend some code prevent me needing 2 seperate macro's that do almost the same thing.
I have workbooks which I have to save 3 worksheets, SU, MER and PF and I have to save these as .txt in a specific Directory. However, there are some workbooks which don't require/contain the SU and MER sheets.
I would like to be able to have one button (in my QAT) that can evaluate whether all 3 sheets are there, or just the PF sheet and save accordindgly. There will always be other sheets in these workbooks that do not require saving (only use for calculations)
I snatched the bones of this code from another thread, but I can't get it to work:
If anyone can point me in the right direction or offer any advice, I'd appreciate it.
I am trying to amend some code prevent me needing 2 seperate macro's that do almost the same thing.
I have workbooks which I have to save 3 worksheets, SU, MER and PF and I have to save these as .txt in a specific Directory. However, there are some workbooks which don't require/contain the SU and MER sheets.
I would like to be able to have one button (in my QAT) that can evaluate whether all 3 sheets are there, or just the PF sheet and save accordindgly. There will always be other sheets in these workbooks that do not require saving (only use for calculations)
I snatched the bones of this code from another thread, but I can't get it to work:
Code:
Sub FetaCheeseElves()
Dim i As Long
Application.DisplayAlerts = False
For i = 1 To Worksheets.Count
Select Case Sheets(i).Name
Case "PF"
ChDir "C:\TRANSIT"
Sheets("PF").Select
Application.SaveAs Filename:="C:\TRANSIT\TRANSIT.txt", FileFormat:= _
xlText, CreateBackup:=False
Case Else
ChDir "C:\TRANSIT"
Sheets("PF").Select
Application.SaveAs Filename:="C:\TRANSIT\TRANSIT.txt", FileFormat:= _
xlText, CreateBackup:=False
Sheets("MER").Select
Application.SaveAs Filename:="C:\TRANSIT\SEEDS.txt", FileFormat:= _
xlText, CreateBackup:=False
Sheets("SU").Select
Application.SaveAs Filename:="C:\TRANSIT\LEVELS.txt", FileFormat:= _
xlText, CreateBackup:=False
End Select
Next i
Application.DisplayAlerts = True
End Sub
If anyone can point me in the right direction or offer any advice, I'd appreciate it.