+ Reply to Thread
Results 1 to 4 of 4

Referencing a worksheet before it is created?!

Hybrid View

  1. #1
    Registered User
    Join Date
    01-16-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Referencing a worksheet before it is created?!

    Hi,

    I have a worksheet (attached) that once filled in, a button is pressed and a new sheet is created which stores the data, and the original sheet is then cleared so it can be filled in again. I would like to automatically chart the data each week as it is filled in - but obviously I can't tell the chart plotter what worksheets to reference until they are actually created, as I don't know what they will be called (it all depends on what date the data is entered). Is there a way around this problem?

    Thanks!

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Referencing a worksheet before it is created?!

    There's no attachment.

    Data should be stored on one sheet with a column for dates
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    01-16-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Referencing a worksheet before it is created?!

    Apologies. Here it is. I'm not sure how I can get all the data to go into one sheet.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    12-27-2009
    Location
    Paris, France
    MS-Off Ver
    Excel 2003
    Posts
    64

    Re: Referencing a worksheet before it is created?!

    Hello,

    Insofar as I understand your problem here is a track

    1) copy the following code in a standard module

    '### Adapt the constant ###
    Const SOURCE As String = "Sheet1"
    '##########################
    
    Sub makeasheet()
    Dim mydate As String
    Dim S As Worksheet
    Application.ScreenUpdating = False
    If Sheets(SOURCE).Range("b8") = "" Then
      MsgBox "Date not entered in ''B8''"
      Exit Sub
    End If
    mydate = Application.WorksheetFunction.Text(Range("b8"), "dd-mm-yyyy")
    On Error Resume Next
    Set S = ActiveWorkbook.Sheets(mydate)
    If Not S Is Nothing Then
      MsgBox "Date in use !" & vbCrLf & "either delete appropriate sheet or use another date", vbInformation
      Exit Sub
    End If
    Err.Clear
    On Error GoTo 0
    Sheets(SOURCE).Copy After:=Sheets(SOURCE)
    Set S = ActiveSheet
    S.Name = mydate '///
    S.Shapes("Button 1").Delete
    With Sheets(SOURCE)
      .Range("B2:E6,B8").ClearContents
      .Activate
    End With
    End Sub
    2) create your chart in the worksheet "Sheet1", it will automatically be carried in the new sheet set.

    Best regards.

    PMO
    Patrick Morange
    Attached Files Attached Files

+ 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