Results 1 to 4 of 4

Problem with add a sheet to workbook macro

Threaded View

  1. #1
    Registered User
    Join Date
    02-28-2008
    Posts
    36

    Problem with add a sheet to workbook macro

    I have a workbook where I have a button to add a sheet, this works fine except for a formula that the macro edits on every sheet so we can have a running total quantity for the project. The problems occurs if the user changes the name of the last sheet in the workbook, then adds a sheet then the formula gets a reference error. The sheets are named 1 , 2 ,3 and so on, but it is nice to be able to change tha name of the sheet to the date.

    Here is the code that Im have problems with

     ' Dim ShtName As String
        ShtName = Sheets.Count - 3
        Range("F36:F37").Select
        ActiveCell.FormulaR1C1 = "=R[-2]C+'" & ShtName & "'!RC:R[1]C"
    is there a code that would always reference the the previous sheet or I know that every sheet has 2 names a permanent sheet name that is Sheet1 Sheet2 and so on and the name that is shown on the tab at the bottom of the workbook, is there a way I can reference the permanent sheet name that would be a variable because I always need this formula to go to the previous page.

    Any help is appreciated.
    Thanks
    Last edited by westonkw; 08-24-2009 at 10:49 AM.

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