Printing multiple copies instead of single

Agates

New Member
Joined
Jul 13, 2012
Messages
29
Everything seems to work fine with code except printing, it is printing multiple copies of the form instead of a single.

Not sure what is going on here, any help would be greatly appreciated.

Code:
Private Sub EnterPrint_cmd_Click()
Dim iRow As Long
Dim ws As Worksheet, txtSamp As Variant
Set ws = Worksheets("SampleLog")
Dim ts As Date
ts = Now
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for Person
    If Trim(Me.txtPerson.Value) = "" Then
        Me.txtPerson.SetFocus
        MsgBox "Please enter Person"
        Exit Sub
    End If
'check for a Sample Id
    If Trim(Me.txtSample1.Value) = "" Then
        Me.txtSample1.SetFocus
            MsgBox "Please enter a Sample Id"
            Exit Sub
    End If
'Create array for textboxes
txtSamp = Array(txtSample1, txtSample2, txtSample3, txtSample4, txtSample5, txtSample6, txtSample7, _
txtSample8, txtSample9, txtSample10, txtSample11, txtSample12, txtSample13, txtSample14)
    For i = 0 To 13
        If txtSamp(i).Value <> "" Then 'Test each tb for value
            ws.Cells(iRow + i, 1) = txtSamp(i) 'Post value
        End If
    Next
    For j = 0 To 13
        If ws.Cells(iRow + j, 1) <> "" Then 'Test if value entered in range col A
        ws.Cells(iRow + j, 2) = ts 'Date/time stamp
        End If
     
     
     'Fill Form
     Range("Form!G6").Value = ts
     Range("Form!D30").Value = ts
     Range("Form!I6").Value = txtPerson
     Range("Form!C9").Value = txtSample1
     Range("Form!C10").Value = txtSample2
     Range("Form!C11").Value = txtSample3
     Range("Form!C12").Value = txtSample4
     Range("Form!C13").Value = txtSample5
     Range("Form!C14").Value = txtSample6
     Range("Form!C15").Value = txtSample7
     Range("Form!C16").Value = txtSample8
     Range("Form!C17").Value = txtSample9
     Range("Form!C18").Value = txtSample10
     Range("Form!C19").Value = txtSample11
     Range("Form!C20").Value = txtSample12
     Range("Form!C21").Value = txtSample13
     Range("Form!C22").Value = txtSample14
     
     'Print Form
    ScreenUpdating = False
    Sheets("Form").Visible = True
    Sheets("Form").Select
    ActiveSheet.PrintOut
      
     'Clear Form
    Sheets("Form").Select
    Range("I6,G6,C9:C28,D30:E30").Select
    Selection.ClearContents
    Sheets("Form").Visible = False
    ScreenUpdating = True
    
    Next
    For k = 0 To 13 'Clean up
        txtSamp(k).Value = ""
    Next
    txtPerson.Value = ""
    txtPerson.SetFocus
    ActiveWorkbook.Save
End Sub
 

Some videos you may like

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Snakehips

Well-known Member
Joined
May 17, 2009
Messages
5,069
Office Version
  1. 2013
Platform
  1. Windows
Agates,

It would appear that your print code is within your first for / next loop ifor j.

Try moving the first Next up to above 'Fill form

Hope that helps.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,594
Messages
5,597,073
Members
414,121
Latest member
DamianX88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top