Solved

Save as VBA Excel

Posted on 2014-03-14
2
409 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 33

Accepted Solution

by:
Norie earned 300 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

777 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