+ Reply to Thread
Results 1 to 2 of 2

Populate Form & Print From Datasource

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-24-2010
    Location
    South Africa
    MS-Off Ver
    Office 2003; Office 2007; Office 2010 (Prefered)
    Posts
    102

    Lightbulb Populate Form & Print From Datasource

    Hi All,

    I need some help with a Marco that will make the printing of a form a bit easier. I have a data source which has +/- 100 users on it. Each user has a unique serial codes that need to be populated on a form.

    Is there a macro that can be used to take the information from all the columns, populate this information into the relevant fields on the form and to print it? Once the one is done, to then move onto the next?

    Any help here is appreciated.

  2. #2
    Forum Contributor
    Join Date
    12-24-2010
    Location
    South Africa
    MS-Off Ver
    Office 2003; Office 2007; Office 2010 (Prefered)
    Posts
    102

    Cool Re: Populate Form & Print From Datasource

    Solution found

    Function RangeName(sName As String) As String
        RangeName = Application.Substitute(sName, " ", "_")
    End Function
    Sub MergePrint()
    'set up your merge form by naming the merge fields _
     with the same name as the data fields you are importing.
    'if any data field contains spaces, then substitute an _
     UNDERSCORE character for each space in the name.
        Dim wsForm As Worksheet, wsData As Worksheet
        Dim sRngName As String, r As Long, c As Integer
        Set wsForm = Worksheets("form") 'change to your sheet name
        Set wsData = Worksheets("datadetails") 'change to your sheet name
        With wsData.Cells(1, 1).CurrentRegion
            For r = 2 To .Rows.Count
                If Not wsData.Cells(r, 1).EntireRow.Hidden Then
                    For c = 1 To .Columns.Count
                        sRngName = wsData.Cells(1, c).Value
                        Range(RangeName(sRngName)).Value = wsData.Cells(r, c)
                    Next
                    wsForm.PrintOut
                End If
            Next
        End With
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Want to auto-populate an order form from a storeroom count form
    By bezam in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-17-2014, 09:02 PM
  2. Replies: 1
    Last Post: 02-28-2013, 08:17 AM
  3. Calling a user form initialize sub when entering the form to populate combobox...
    By regupnorth in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-02-2012, 07:24 AM
  4. User Form to Populate, print and clear multiple spreadsheets
    By ejschulte2001 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-14-2010, 11:35 PM
  5. Add buttons in a form from a datasource
    By justagirl in forum Excel General
    Replies: 0
    Last Post: 08-03-2005, 01:05 PM

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