Consulting

Results 1 to 4 of 4

Thread: CREATE WORKBOOKS FROM TEMPLATE WORKSHEET AND TABLE OF DATA

  1. #1
    VBAX Regular
    Joined
    Dec 2020
    Posts
    48
    Location

    CREATE WORKBOOKS FROM TEMPLATE WORKSHEET AND TABLE OF DATA

    Hi,
    Hopefully can explain this well enough, I've attached a workbook with 2 Worksheets , CTR Data & CTR Out

    I'm after some code that can create a new workbook from the CTR Out Template once its been populated in sequence with the values from the table in the CTR Data Sheet. The Name of the file is the 'Number' (which I also required within cell c5 on the CTR out.

    The CTR Data table {CTR_Data} could be anything from 1 to 50 rows long.

    Thanks In Advance
    Attached Files Attached Files

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    Sub blah()
    With Sheets("CTR Out")
      For Each rw In Range("CTR_DATA").ListObject.DataBodyRange.Rows
        .Range("C5,C11,C14:C17").ClearContents
        .Range("C5").Value = rw.Cells(1).Value
        .Range("C11").Value = rw.Cells(2).Value
        .Range("C14").Value = rw.Cells(3).Value
        .Range("C15").Value = rw.Cells(4).Value
        .Range("C16").Value = rw.Cells(5).Value
        .Range("C17").Value = rw.Cells(6).Value
        .Copy
        ActiveWorkbook.Close True, "C:\Users\Public\Documents\" & rw.Cells(1).Value '<<< adjust the path for your system
      Next rw
      .Range("C5,C11,C14:C17").ClearContents
    End With
    End Sub
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Regular
    Joined
    Dec 2020
    Posts
    48
    Location
    Off to try this straight away!!!!

    Thank you so much for this!

  4. #4
    VBAX Regular
    Joined
    Dec 2020
    Posts
    48
    Location
    Brilliant ! I've been trying to figure this out and searched the web high and low all week. I owe you a beer or two or more!

Posting Permissions

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