Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Save As issue

I have the following code that deletes sheets based on
values in certain cells.
The problem is, I would like the option of deleting others
sheets based on information given by the person filling out
the form. I would like a message box to pop up that the
person can answer yes or no to. If the answer is no than
delete Sheets 1, 5, 7.
I would like to incorperate into the following macro.

Sub Save_As()
Dim FName1 As String, FName2 As String
Dim FName3 As String, Fullname As String
FName1 = "CK0"
FName2 = Range("AU2").Value & "-"
FName3 = Range("J4").Value
Fullname = FName1 & FName2 & FName3
Application.DisplayAlerts = False
ChDrive "G"
ChDir "G:\New"
With ActiveSheet
If .Range("BJ31").Value = "No" Then
Worksheets(Array("Sheet16", " Sheet26", "
Sheet31")).Delete
ElseIf .Range("BJ31").Value = "Yes" Then
Worksheets(Array("Sheet15")).Delete
End If
If .Range("N32").Value = "Adult" Then
Worksheets(Array("Sheet19, " Sheet20", "
Sheet21", " Sheet22", " Sheet23", " Sheet24")).Delete
ElseIf .Range("N32").Value = "Youth" Then
Worksheets(Array("Sheet14", " Sheet15", "
Sheet17", " Sheet7")).Delete
End If
End With
ActiveWorkbook.SaveAs Fullname, _
FileFormat:=xlNormal, _
CreateBackup:=False, _
Accessmode:=xlShared
MsgBox "Saved to " & CurDir & " - " & Fullname

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Save As issue

Logan,

The basic code would be something like

Dim Result As Long
Result = MsgBox("Answer yes or no.",vbYesNo)
If Result = vbNo Then
Worksheets(Array("Sheet1","Sheet5","Sheet7")).Dele te
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Logan" wrote in message
...
I have the following code that deletes sheets based on
values in certain cells.
The problem is, I would like the option of deleting others
sheets based on information given by the person filling out
the form. I would like a message box to pop up that the
person can answer yes or no to. If the answer is no than
delete Sheets 1, 5, 7.
I would like to incorperate into the following macro.

Sub Save_As()
Dim FName1 As String, FName2 As String
Dim FName3 As String, Fullname As String
FName1 = "CK0"
FName2 = Range("AU2").Value & "-"
FName3 = Range("J4").Value
Fullname = FName1 & FName2 & FName3
Application.DisplayAlerts = False
ChDrive "G"
ChDir "G:\New"
With ActiveSheet
If .Range("BJ31").Value = "No" Then
Worksheets(Array("Sheet16", " Sheet26", "
Sheet31")).Delete
ElseIf .Range("BJ31").Value = "Yes" Then
Worksheets(Array("Sheet15")).Delete
End If
If .Range("N32").Value = "Adult" Then
Worksheets(Array("Sheet19, " Sheet20", "
Sheet21", " Sheet22", " Sheet23", " Sheet24")).Delete
ElseIf .Range("N32").Value = "Youth" Then
Worksheets(Array("Sheet14", " Sheet15", "
Sheet17", " Sheet7")).Delete
End If
End With
ActiveWorkbook.SaveAs Fullname, _
FileFormat:=xlNormal, _
CreateBackup:=False, _
Accessmode:=xlShared
MsgBox "Saved to " & CurDir & " - " & Fullname

End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Save As issue

Thanks, Chip
That worked


-----Original Message-----
Logan,

The basic code would be something like

Dim Result As Long
Result = MsgBox("Answer yes or no.",vbYesNo)
If Result = vbNo Then
Worksheets(Array("Sheet1","Sheet5","Sheet7")).Dele te
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Logan" wrote in message
...
I have the following code that deletes sheets based on
values in certain cells.
The problem is, I would like the option of deleting others
sheets based on information given by the person filling out
the form. I would like a message box to pop up that the
person can answer yes or no to. If the answer is no than
delete Sheets 1, 5, 7.
I would like to incorperate into the following macro.

Sub Save_As()
Dim FName1 As String, FName2 As String
Dim FName3 As String, Fullname As String
FName1 = "CK0"
FName2 = Range("AU2").Value & "-"
FName3 = Range("J4").Value
Fullname = FName1 & FName2 & FName3
Application.DisplayAlerts = False
ChDrive "G"
ChDir "G:\New"
With ActiveSheet
If .Range("BJ31").Value = "No" Then
Worksheets(Array("Sheet16", " Sheet26", "
Sheet31")).Delete
ElseIf .Range("BJ31").Value = "Yes" Then
Worksheets(Array("Sheet15")).Delete
End If
If .Range("N32").Value = "Adult" Then
Worksheets(Array("Sheet19, " Sheet20", "
Sheet21", " Sheet22", " Sheet23", " Sheet24")).Delete
ElseIf .Range("N32").Value = "Youth" Then
Worksheets(Array("Sheet14", " Sheet15", "
Sheet17", " Sheet7")).Delete
End If
End With
ActiveWorkbook.SaveAs Fullname, _
FileFormat:=xlNormal, _
CreateBackup:=False, _
Accessmode:=xlShared
MsgBox "Saved to " & CurDir & " - " & Fullname

End Sub




.

Reply
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
Save As csv Carraige Return issue WaterBug Excel Worksheet Functions 3 May 6th 10 04:09 PM
save as issue jatman Excel Discussion (Misc queries) 1 March 21st 08 09:41 AM
File Save/Save As Issue Josh O. Setting up and Configuration of Excel 3 August 28th 07 06:33 PM
Save As Authentication Issue From ASP.NET Matt Schwartz Excel Discussion (Misc queries) 0 June 9th 06 05:34 AM
UserForm Save Issue DarnTootn Excel Worksheet Functions 0 May 11th 06 05:15 PM


All times are GMT +1. The time now is 06:03 PM.

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

About Us

"It's about Microsoft Excel"