+ Reply to Thread
Results 1 to 1 of 1

Debug macro that saves file

  1. #1
    Registered User
    Join Date
    12-22-2011
    Location
    Berlin, Germany
    MS-Off Ver
    Excel 2010
    Posts
    58

    Debug macro that saves file

    Hi all,

    I'm having trouble debugging this macro that asks the user if they're sure about saving, saves the file as a specific name, and then deletes entries in the workbook. The error comes up in the "ThisFile" line.


    Private Sub CommandButton1_Click()

    If MsgBox("Are you sure you want to save and open a new chart? This chart will disappear and a new chart will be created.", vbYesNo) = vbNo Then Exit Sub

    ThisFile = Range("Data!X1").Value & "." & Range("Data!Z1").Value & "." & Range("Data!Y1").Value & "." & Format(Date, "mmdd") & ".xlsm"
    ActiveWorkbook.SaveAs Filename:="C:\My Documents\SPC\" & ThisFile

    Range("A3").Select
    ActiveCell.FormulaR1C1 = "1"
    Range("B4:AG12").Select
    Selection.ClearContents
    Range("B3:N3").Select
    Selection.ClearContents
    ActiveWindow.SmallScroll Down:=12
    Range("B30:AG30").Select
    Selection.ClearContents
    ActiveWindow.SmallScroll Down:=-24

    End Sub
    Last edited by Subject_Name_Here; 03-10-2012 at 01:30 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1