Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

conditional copy macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert Kettle - 30 May 2008 22:37 GMT
I am looking to set up a macro that will conditionally copy multiple cells
from one worksheet to another and print after each.

Example.

There are two worksheets DATA and REPORT.

For each occurence of TRUE in column A on the DATA worksheet, I want to copy
the corresponding value of column B to REPORT cell H2 (ie. A3=TRUE, copy B3 :
 A10=TRUE, copy B10), then print the REPORT worksheet and repeat until all
TRUE rows from DATA have been printed.

Thanks for your help.
Chris - 30 May 2008 23:05 GMT
On May 30, 2:37 pm, Robert Kettle
<RobertKet...@discussions.microsoft.com> wrote:
> I am looking to set up a macro that will conditionally copy multiple cells
> from one worksheet to another and print after each.
[quoted text clipped - 9 lines]
>
> Thanks for your help.

Robert,

Try this:

Sub ReportPrint()

Application.ScreenUpdating = False
'x = row number
x = 1

'Loop until reach blank cell in column A
Do Until Cells(x, 1).Value = ""
'Copy cell to Report sheet if True in column A
   If Cells(x, 1).Value = True Then
   Cells(x, 2).Select
   Selection.Copy
   Sheets("Report").Select
   Range("H2").Select
   ActiveSheet.Paste
   Application.CutCopyMode = False

'Print report sheet
   ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
   Sheets("Data").Select

  End If
 x = x + 1
Loop

Application.ScreenUpdating = True
End Sub

Good Luck!
Chris
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.