PDA

View Full Version : Solved: VBA help



HeathAN
07-01-2013, 11:58 PM
Hi,

I am trying to work out how to set up a macro (or VBA) in order to print a page and then pull information form the next row down, rinse and repeat.

The first worksheet I have is for data entry (called Enter Discounts) this has a list that must be manually entered. Also next to each line is a checkbox so I can select whether to print it or not. So I need some thing to check the TRUE/FALSE value, update another worksheet called Ticket with the name from the first worksheet, then print out that worksheet only if the value is TRUE (ie checkbox selected).

Then it needs to go to the next line and do the same thing.

Any help would be greatly appreciated.

SamT
07-02-2013, 12:06 PM
For each Row with a True, you want to print another ticket?

I think we need an example. Upload a workbook with two sheets, one with a few lines from the Data entry sheet with dummy data and the other with a Ticket form with data from one line from the first sheet.

HeathAN
07-02-2013, 04:29 PM
10213

Sample attached

HeathAN
07-03-2013, 05:53 PM
SOLVED

Sub PrintAll()
Dim wshInput As Worksheet
Dim wshPrint As Worksheet
Dim lngRow As Long
Dim lngLastRow As Long

Set wshInput = Worksheets("ENTER DISCOUNTS")
Set wshPrint = Worksheets("TICKET")

With wshInput
lngLastRow = .Range("A" & .Rows.Count).End(xlUp).Row
For lngRow = 3 To lngLastRow
If wshInput.Range("D" & lngRow) = True Then
wshPrint.Range("A2").Value = .Range("A" & lngRow).Value
wshPrint.PrintOut
End If
Next lngRow
End With
End Sub

SamT
07-04-2013, 05:25 AM
:thumb

snb
07-04-2013, 07:38 AM
or


Sub M_PrintAll_snb()
For each cl in Sheets("ENTER DISCOUNTS").columns(1).specialcells(2)
If cl.row >2 and cl.offset(,3) Then
Sheets("TICKET").cells(2,1) = cl.value
Sheets("TICKET").PrintOut
End If
Next
End Sub