Solved

Save as VBA Excel

Posted on 2014-03-14
2
403 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:Wass_QA
2 Comments
 
LVL 33

Accepted Solution

by:
Norie earned 300 total points
Comment Utility
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:Wass_QA
Comment Utility
Super,
thank you.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now