Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Save as VBA Excel

Posted on 2014-03-14
2
Medium Priority
?
431 Views
Last Modified: 2014-03-14
Hello,
Can you please help,
I'm trying to save the sheet (range) as a cell value.
but I keep getting error.

example,, Cell c2  is  
Orders Count_between (02/01/14 _ 02/28/14)

Sub Save_Operator()
    Sheets("Operator").Select
    Range("A1:G100").Select
    Selection.Copy
    Workbooks.Add
    ActiveSheet.Paste
    ActiveWorkbook.SaveAs Filename:= _
    "C:\Users\Wassim.\Desktop\" & Range("C1") & ."xlsx", FileFormat:=51, CreateBackup:=False
    ActiveWorkbook.Close
  MsgBox "Done"
End Sub

Thank you for your help,
0
Comment
Question by:W.E.B
2 Comments
 
LVL 35

Accepted Solution

by:
Norie earned 1200 total points
ID: 39930595
You'll need to replace the / in the dates.

This will replace them with -.
Sub Save_Operator()

    Sheets("Operator").Range("A1:G100").Copy
    Workbooks.Add (xlWBATWorksheet)
    ActiveSheet.Paste
    ActiveWorkbook.SaveAs _
        Filename:="C:\Users\Wassim.\Desktop\" & Replace(Range("C1"), "/", "-") & ".xlsx", FileFormat:=51
    ActiveWorkbook.Close

    MsgBox "Done"
    
End Sub

Open in new window

0
 

Author Closing Comment

by:W.E.B
ID: 39930609
Super,
thank you.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question