Consulting

Results 1 to 6 of 6

Thread: Solved: Print Data into Form

  1. #1

    Solved: Print Data into Form

    Hi Guz-n-Galz,

    Picture This - Data in Rows (Sheet1) - Format/Form (Sheet2)

    What would be the best approach to print all data that are in rows (Sheet1) into the Format/Form (Sheet2) - one after another till all existing rows are complete.

    Anything would be acceptable - views/ideas/formats/links.

    Thx-n-BR

  2. #2

    Problem in starting the Loop from row 7

    Hi Everybody,

    After searching the net and mixing code together I have tried to solve the printing Form query, but I have hit another

    The code works fine if the header is in the first row and the data follows.

    But...

    How do I change the code if the heading is in row 6 data starts from row 7 ???

    Can anybody help me to amend the code below.

    [VBA]Public Sub ProcessData()
    Dim LastRow As Long
    Dim i As Long
    With Worksheets("Master")
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    For i = 2 To LastRow
    Sheets("Summary").Select
    Worksheets("Summary").PrintOut
    .Rows(2).Copy .Rows(LastRow + 1)
    .Rows(3).Resize(LastRow - 2).Copy .Range("A2")
    .Rows(LastRow).Delete
    Next i
    End With
    MsgBox "Finished Processing"
    End Sub
    [/VBA]

    Thx-n-BR
    Attached Files Attached Files

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Try changing the line
    [VBA]For i = 2 to LastRow[/VBA]
    to
    [VBA]For i = 7 to LastRow [/VBA]
    and see what happens
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    I tried doing that...

    The code runs ok for the first time

    But...

    The information in the Master flap automatically changes - and goes for a toss.

    Kindly view file.

    Thx-n-BR
    Attached Files Attached Files
    Last edited by parttime_guy; 08-30-2011 at 07:57 PM.

  5. #5
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    I don't have time to test this right now.

    [VBA]Public Sub ProcessData()
    Dim LastRow As Long, startDataRow As Long
    Dim i As Long

    With Worksheets("Master")
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    startDataRow = Range("A" & Rows.Count).End(xlUp).Row
    startDataRow = Range("A" & startDataRow).End(xlUp).Row - 1
    If startDataRow > LastRow Then Exit Sub

    For i = startDataRow To LastRow

    Sheets("Summary").Select

    Worksheets("Summary").PrintOut
    .Rows(startDataRow).Copy .Rows(LastRow + 1)
    .Rows(startDataRow + 1).Resize(LastRow - startDataRow).Copy .Range("A" & startDataRow)
    .Rows(LastRow).Delete
    Next i
    End With

    MsgBox "Finished Processing"

    End Sub[/VBA]

    A better approach might be to use the method that John Walkenbach used in his ElephantsRus. He used Indirect() to fill the form cells based on a row cell. To print, you then just iterate the rows from the start row to the end row.

  6. #6
    Thx Kenneth for ur reply - it works like a charm (...except there are 2 extra pages that get printed - but I'll live with that).

    But the data in in the Master file remains intact that's what really matters.

    I have downloaded John Walkenbach "ElephantsRus" will take a look at it.



    Best regards

Posting Permissions

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