Transfer data to another sheet based on criteria and save as PDF

manona

New Member
Joined
Mar 22, 2016
Messages
40
Hi,

I am trying to copy information to another tab based on a criteria, and save as PDF.

I know how to copy different cells from one tab and paste in different cells in another tab, but this time I need to copy values only if there is no 'Yes' in the column D (starting at row 2). Once the data is transferred, I would like for it to save as a PDF under the value in column B (which is 'name'), and go back to the original tab and look for the next row with data that does not have 'Yes' in column D.

I would like this macro to be a 'button' macro (to click on a shape to initiate the macro).

Any help is appreciated, thank you in advance. :)

Manon
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Code:
Sub Macro1()
Dim a As Long
For a = 2 To Cells(Rows.Count, 4).End(xlUp).Row
If Cells(a, 4) <> "Yes" Then
Cells(a, 4).Copy
Sheets("sheet2").Range("A1").PasteSpecial
      Sheets("sheet2").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "C:\excelmacro\ravi" & Cells(a, 2) & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties _
        :=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
        End If
        Next a
        MsgBox "complete"
End Sub
change file path and run the macro
ravishankar
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,173
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top