Consulting

Results 1 to 5 of 5

Thread: Excel templates and save as workbook

  1. #1

    Excel templates and save as workbook

    Hi all,

    I am trying to populate a new workbook with the data in a list box using standard template. I have a data in the listbox with employer details and I want to populate these details in a standard template , once the template is filled with the employer details , the template should be saved with individual employer details
    Ex : If I have 5 employers .. I want to generate a workbook with 5 different tabs ( shown in output file )

    Here attached the files for the reference.

    Could anybody can share me the solution .

    Thanks
    Bittu
    Attached Files Attached Files

  2. #2
    Any one plz ..

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Something like this maybe



    Option Explicit
    
    Sub Macro1()
        Dim wb1 As Workbook, wb2 As Workbook
        Dim wsEmployees As Worksheet, wsTemplate1 As Worksheet, wsTemplate2 As Worksheet
        Dim rEmployees As Range
        Dim iEmployee As Long, iDatum As Long
        
        
        Set wb1 = ThisWorkbook
        Set wsEmployees = wb1.Worksheets("Data")
        Set wsTemplate1 = wb1.Worksheets("template")
        Set rEmployees = wsEmployees.Cells(1, 1).CurrentRegion
        
        Application.ScreenUpdating = False
        
        For iEmployee = 2 To rEmployees.Rows.Count
            If wb2 Is Nothing Then
                wsTemplate1.Copy
                Set wb2 = ActiveWorkbook
                Set wsTemplate2 = ActiveSheet
            Else
                wsTemplate1.Copy After:=wb2.Worksheets(wb2.Worksheets.Count)
                Set wsTemplate2 = ActiveSheet
            End If
            
            For iDatum = 1 To rEmployees.Columns.Count
                wsTemplate2.Cells(2 + iDatum, 3).Value = rEmployees.Cells(iEmployee, iDatum).Value
            Next iDatum
            
            wsTemplate2.Name = rEmployees.Cells(iEmployee, 3)
        
        Next iEmployee
        
        Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  4. #4
    Awesome Paul , It is working

    Thanks again
    Bittu

  5. #5
    Hi Paul ,
    Is that possible if the template is located in other file ( only template) and I want to generate the output results in the data form ?

    Thanks

Tags for this Thread

Posting Permissions

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