+ Reply to Thread
Results 1 to 3 of 3

Macro to create new sheets from master data sheet

  1. #1
    Registered User
    Join Date
    10-03-2006
    Posts
    2

    Macro to create new sheets from master data sheet

    I would like to create a macro that allows me to take data from one spreadsheet and populate various new sheets for billing purposes. For example, the data sheet includes fields for client name, billable account, billable value, etc. I would like to be able to fill in this data and then run a macro to create a new sheet (bill) for each client that plugs in values from the data sheet. I only know how to create a macro for one client at a time and then rename each sheet with the client short name (which is also a cell value on the sheet).

    Here's the code, but I'm pretty certain it's a roundabout way of doing this:

    Sheets("CLIENT TEMPLATE").Select
    Sheets("CLIENT TEMPLATE").Copy
    ActiveWorkbook.Colors = Workbooks("3rd Qtr 2006_1 - TEST.xls").Colors
    Range("A2:H2").Select
    ActiveCell.FormulaR1C1 = "='TEST DATA SHEET'!R[2]C[1]"
    Range("F8").Select
    ActiveCell.FormulaR1C1 = "='TEST DATA SHEET'!R[-4]C[-2]"
    Range("F9").Select
    ActiveCell.FormulaR1C1 = "='TEST DATA SHEET'!R[-5]C[-1]"
    Range("C25").Select
    ActiveCell.FormulaR1C1 = _
    "=IF('TEST DATA SHEET'!R[-21]C[5]="""","""",'TEST DATA SHEET'!R[-21]C[5])"
    Range("E25").Select
    ActiveCell.FormulaR1C1 = _
    "=IF('TEST DATA SHEET'!R[-21]C[4]="""","""",'TEST DATA SHEET'!R[-21]C[4])"
    Range("F25").Select
    ActiveCell.FormulaR1C1 = "='TEST DATA SHEET'!R[-21]C[1]"
    Range("F29").Select
    ActiveCell.FormulaR1C1 = "='TEST DATA SHEET'!R[-25]C[-3]"
    Range("J1").Select
    ActiveCell.FormulaR1C1 = "='TEST DATA SHEET'!R[3]C[-9]"


    End Sub

    Any help would be graetly appreciated. Thanks

  2. #2
    Forum Contributor
    Join Date
    12-12-2005
    Posts
    667
    Perhaps you should make a template and copy it:
    Sub Macro2()
    '
    ' Macro2 Macro
    ' Macro recorded 10/4/2006 by Administrator
    '

    '
    Workbooks.Add
    Windows("Test.xls").Activate
    Sheets("Sheet1").Copy Before:=Workbooks("Book2").Sheets(1)
    End Sub
    Best regards,

    Ray

  3. #3
    Registered User
    Join Date
    10-03-2006
    Posts
    2
    I'm sorry I don't know VBA that well. If I have a template, how can I tell it to be filled from the various rows of data on the other sheet? For example, on the template, the cell range A2:H2 (a merged cell) must equal B4 on the first sheet, then B5, B6, and so on. And Cell F9 on the template must equal E4 on the first sheet, then E5, E6, and so on.

+ 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