Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a template that I want to fill in a cell from another worksheet
(project #) and then print the template which fills in other pertenent information. The project # range is variable. How can I create a loop to select the first cell, copy and paste to the template, print the template and then repeat the process until all project #s have been selected? Thanks so much. KK |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi KK
Wih this macro I assume that Project# workbook is open, and project# is in column A starting in row 2. TargetCell is the project# cell in the template. Sub test() Dim ProjectWB As Workbook Set ProjectWB = Workbooks("Project#.xls") TargetCell = "A1" ' change to suit ProjectNumCol = "A" StartRow = 2 ' Assuming headings in row 1 LastRow = ProjectWB.Worksheets("Sheet1"). _ Cells(StartRow, ProjectNumCol).End(xlDown).Row For r = 1 To LastRow Range(TargetCell) = ProjectWB.Worksheets _ ("Sheet1").Cells(r, ProjectNumCol) ThisWorkbook.PrintOut Next End Sub Regards, Per "KalliKay" skrev i meddelelsen ... I have a template that I want to fill in a cell from another worksheet (project #) and then print the template which fills in other pertenent information. The project # range is variable. How can I create a loop to select the first cell, copy and paste to the template, print the template and then repeat the process until all project #s have been selected? Thanks so much. KK |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks so much. I used some of your code in combination with some other and
it worked great. KK "Per Jessen" wrote: Hi KK Wih this macro I assume that Project# workbook is open, and project# is in column A starting in row 2. TargetCell is the project# cell in the template. Sub test() Dim ProjectWB As Workbook Set ProjectWB = Workbooks("Project#.xls") TargetCell = "A1" ' change to suit ProjectNumCol = "A" StartRow = 2 ' Assuming headings in row 1 LastRow = ProjectWB.Worksheets("Sheet1"). _ Cells(StartRow, ProjectNumCol).End(xlDown).Row For r = 1 To LastRow Range(TargetCell) = ProjectWB.Worksheets _ ("Sheet1").Cells(r, ProjectNumCol) ThisWorkbook.PrintOut Next End Sub Regards, Per "KalliKay" skrev i meddelelsen ... I have a template that I want to fill in a cell from another worksheet (project #) and then print the template which fills in other pertenent information. The project # range is variable. How can I create a loop to select the first cell, copy and paste to the template, print the template and then repeat the process until all project #s have been selected? Thanks so much. KK |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Loop Macro | Excel Programming | |||
Help with using a Macro Loop | Excel Discussion (Misc queries) | |||
Do until loop with use of another macro in loop | Excel Programming | |||
Macro - Loop or Next | Excel Programming | |||
macro loop | Excel Discussion (Misc queries) |