ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   print form with data from other sheet (https://www.excelbanter.com/excel-programming/372090-print-form-data-other-sheet.html)

milos

print form with data from other sheet
 
I have a script for printing form (sheet "PZ") with data from one sheet
(sheet "list") from active cell in sheet "list". And I want to use in this
form also data from another sheet ("projekty") from the same row number as in
sheet "list". But I don't know how...
Can you help me someone. I'm sending the script I tried to use, but it
didn't work.

Sub PrintPZ()
Dim i As Long
Sheets("list").Select
For i = ActiveCell.Row To ActiveCell.Row
Sheets("PZ").Range("C13").Value = Range("C" & i).Value
Sheets("PZ").Range("E32").Value = Sheets("projekty").Range("I" & i).Value
Sheets("PZ").Range("D34").Value = Sheets("projekty").Range("G" & i).Value
Sheets("PZ").PrintOut
End Sub

Dave Peterson

print form with data from other sheet
 
Except for the loop, it looks ok to me:

Sub PrintPZ()
Dim i As Long
Sheets("list").Select
i = ActiveCell.Row
Sheets("PZ").Range("C13").Value = Range("C" & i).Value
Sheets("PZ").Range("E32").Value = Sheets("projekty").Range("I" & i).Value
Sheets("PZ").Range("D34").Value = Sheets("projekty").Range("G" & i).Value
Sheets("PZ").PrintOut preview:=true
End Sub

(preview:=true will save you some trees while you're testing.)

milos wrote:

I have a script for printing form (sheet "PZ") with data from one sheet
(sheet "list") from active cell in sheet "list". And I want to use in this
form also data from another sheet ("projekty") from the same row number as in
sheet "list". But I don't know how...
Can you help me someone. I'm sending the script I tried to use, but it
didn't work.

Sub PrintPZ()
Dim i As Long
Sheets("list").Select
For i = ActiveCell.Row To ActiveCell.Row
Sheets("PZ").Range("C13").Value = Range("C" & i).Value
Sheets("PZ").Range("E32").Value = Sheets("projekty").Range("I" & i).Value
Sheets("PZ").Range("D34").Value = Sheets("projekty").Range("G" & i).Value
Sheets("PZ").PrintOut
End Sub


--

Dave Peterson


All times are GMT +1. The time now is 08:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com