+ Reply to Thread
Results 1 to 2 of 2

Thread: Run Time Error when Selecting Cell VBA

  1. #1
    Registered User
    Join Date
    10-25-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003
    Posts
    1

    Question Run Time Error when Selecting Cell VBA

    Hello all,

    Merry Christmas and Happy New years!
    I am having an issue with VBA Scripting. This is what I've done:

    Sub Create_Dynamic_Forecast()
    '
    ' Create_Dynamic_Forecast
    Application.ScreenUpdating = True
    'ActiveWorkbook.Save
    Sheets.Add After:=Sheets(Sheets.Count)
    ActiveSheet.Name = "Dynamic Forecast"
    Sheets("Emergency Proforma").Select
    Cells.Select
    Range("B1").Activate
    Selection.Copy
    Sheets("Dynamic Forecast").Select
    ActiveSheet.Paste
    ActiveWindow.DisplayGridlines = False
    ActiveSheet.Shapes("Button 1").Select
    Application.CutCopyMode = False
    Selection.Delete
    Application.CutCopyMode = False
    Range("C31").Select
    Selection.ClearContents
    Range("D2:K2").Select
    ActiveCell.FormulaR1C1 = "30 Day Dynamic Forecast"


    Application.ScreenUpdating = True
    MsgBox ("Dynamic Forecast saved to C:\Temp")

    End Sub


    It's working until Range("C31").Select and then it bombs out with:

    "Run-time error '1004': Application-defined or object-defined error"

    I understand that the error relates to forms, controls, and so on but not why its happening. I just want to clear the contents of the cell on the new sheet.

    Believe it or not, i'm not very good at VBA!

  2. #2
    Valued Forum Contributor p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2003-2010
    Posts
    377

    Re: Run Time Error when Selecting Cell VBA

    I tried your code in Excel 2010 and there is no problem.

+ 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.2.0