Copy Data from a different sheet, paste on the specific cell and save as PDF in a specific folder

nbuddhi

New Member
Joined
Jun 23, 2020
Messages
29
Office Version
  1. 365
Platform
  1. Windows
Dear Team,

I have an automated excel sheet, "Test Report" to extract data from a sheet called "Data Base". Basically sheet, "Data Base" column "A" having the test report numbers and other column having other data. Both sheets in same workbook.

There are thousand of test report data included on the sheet "Data Base" and;

Step 1 : I have to copy test report numbers from cell "A2939" of sheet "Data Base" and paste in the cell "E4" of sheet "Test Report".
Step 2 : Then report will be extracted all the required data as already setup.
Step 3 : Test report have to save as a pdf file in folder "E:\D\PDF"
Step 4 : This should be continue one by one report numbers from range "A2939:A4225" of sheet "Data Base". Paste cell "E4" is fixed.

Kindly help me to correct the following macro to fulfill Step 1, 3 & 4

VBA Code:
Private Sub CommandButton3_Click()
    
    For i = 2939 To 4225
    Sheets("Data Base").Range("A" & i).Copy
    Sheets("Test Report").Range("E4").PasteSpecial Paste:=xlPasteValues
  
    Application.CutCopyMode = False
    
Dim fName As String
    With ActiveSheet
        fName = .Range("E4").Value
        .ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
                             "E:\D\PDF\" & fName, Quality:= _
                             xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
                             OpenAfterPublish:=True
          End With
      Next i
End Sub

Thanks & Best Rgds,
Nuwan Buddhika.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,214,638
Messages
6,120,676
Members
448,977
Latest member
moonlight6

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