Print single sheets from rows of data

  • Thread starter Thread starter John
  • Start date Start date
J

John

I have a spreadsheet of 250 employees where annual increases are
calculated, lets call it sheet "A". I also have a separate sheet that
has cells for one employee's data so we can hand a sheet to each
employee, let's call it "B"
I want to be able to: 1)take the information from A 2) grab the
appropriate data from A for one employee 3) drop onto spreadhsheet B
4) print B 5) then repeat the process for each employee. 5) I also
want the code to ingnore rows that don't have a Y in field A or would
ingnore rows that don't have a value in a certain column. Has anyone
already done this? If so I would be most grateful for a VB code
sample.
John
 
Hi John

If you use Vlookup formulas in the cells in Sheets("B") with as lookup value cell A1 of Sheets("B")
and a lookup table in Sheets("A") you can use this macro.

This will change the value of A1 in sheets("B") to the value of the cell in the B Column of sheets("A")
if there is a "Y" in the A Column.
(The B column have the employee names in them for example)

All the cells will be updated with the values of that row.
Print the Sheets("B") and change the value to the next value......

Sub test()
Dim cell As Range
For Each cell In Sheets("B").Cells.SpecialCells(xlCellTypeConstants)
'The B column have the employee names in them
If cell.Offset(-1, 0).Value = "Y" Then
Sheets("B").Range("A1").Value = cell.Value
Sheets("B").PrintOut
End If
Next
End Sub
 
Oops

Sorry

I am confused with your sheetnames<g>
This will work

Sub test()
Dim cell As Range
For Each cell In Sheets("A").Columns("B").Cells.SpecialCells(xlCellTypeConstants)
If cell.Offset(0, -1).Value = "Y" Then
Sheets("B").Range("A1").Value = cell.Value
Sheets("B").PrintOut
End If
Next
End Sub
 
Back
Top