simpleman56
New Member
- Joined
- Apr 6, 2004
- Messages
- 3
Hi Everybody,
I'm new to VB and am having a problem trying to perform a couple of different tasks with one macro. I have been able to find two seperate macros but I need them combined into one. I am trying to
(1) Create a new folder based on the contents of Sheet2.RangeB2
(2) If the folder exists, just skip to the next step
(3) Copy Sheet2 and
(4) Save the sheet into the new folder as Sheet2.RangeB2 & Sheet2.RangeB8
Sheet2.RangeB2 is variable text
Sheet2.RangeB8 is the current date - 6-Apr-04 format
Here are the two macros that I found to accomplish each task individually
Sub Create_Folder()
Dim Msg As String
On Error Resume Next
Msg = "Folder Not Created" & vbCrLf & vbcrl
Msg = Msg & "Make Sure The File Path Is Valid" & vbCrLf
Msg = Msg & "And That It Contains Valid Characters."
MkDir "C:\" & Sheets(2).Range("B2")
If Err <> 0 Then MsgBox Msg, vbCritical
Sub CopyMe()
Dim SaveMeAs As String
SaveMeAs = Sheets("Sheet2").Range("B2") & Sheets("Sheet2").Range("B8").Text
Sheets("Sheet2").Copy
ActiveWorkbook.SaveAs Filename:="C:\My Documents\" & SaveMeAs
End Sub
Thanks in advance for your help
I'm new to VB and am having a problem trying to perform a couple of different tasks with one macro. I have been able to find two seperate macros but I need them combined into one. I am trying to
(1) Create a new folder based on the contents of Sheet2.RangeB2
(2) If the folder exists, just skip to the next step
(3) Copy Sheet2 and
(4) Save the sheet into the new folder as Sheet2.RangeB2 & Sheet2.RangeB8
Sheet2.RangeB2 is variable text
Sheet2.RangeB8 is the current date - 6-Apr-04 format
Here are the two macros that I found to accomplish each task individually
Sub Create_Folder()
Dim Msg As String
On Error Resume Next
Msg = "Folder Not Created" & vbCrLf & vbcrl
Msg = Msg & "Make Sure The File Path Is Valid" & vbCrLf
Msg = Msg & "And That It Contains Valid Characters."
MkDir "C:\" & Sheets(2).Range("B2")
If Err <> 0 Then MsgBox Msg, vbCritical
Sub CopyMe()
Dim SaveMeAs As String
SaveMeAs = Sheets("Sheet2").Range("B2") & Sheets("Sheet2").Range("B8").Text
Sheets("Sheet2").Copy
ActiveWorkbook.SaveAs Filename:="C:\My Documents\" & SaveMeAs
End Sub
Thanks in advance for your help