![]() |
Print single sheets from rows of data
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 |
Print single sheets from rows of data
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 -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "John" wrote in message om... 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 |
Print single sheets from rows of data
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(xlCell TypeConstants) If cell.Offset(0, -1).Value = "Y" Then Sheets("B").Range("A1").Value = cell.Value Sheets("B").PrintOut End If Next End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Ron de Bruin" wrote in message ... 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 -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "John" wrote in message om... 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 |
Print single sheets from rows of data
Thanks much!
John "Ron de Bruin" wrote in message ... 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(xlCell TypeConstants) If cell.Offset(0, -1).Value = "Y" Then Sheets("B").Range("A1").Value = cell.Value Sheets("B").PrintOut End If Next End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl |
All times are GMT +1. The time now is 02:19 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com