Data from one sheet to overide data on another sheet

Daroh

Board Regular
Joined
Aug 19, 2016
Messages
62
HI,

I am trying to add in the code below that the data from sheet3 should be copied and pasted/override the data in Sheet1 A:AA but only it the values in Sheet3 A:A and values in Sheet1 A:A are the same. The value in the first column on both sheets will be a unique number the that person. The range in Sheet1 will have over 5000 people in it (and it is growing) with data spread over 35/40 columns for each person.

Any suggestions or solutions would be very much appreciated.

Thanks in advance.

VBA Code:
Public Sub CreateReports()

Dim myPath As String, wholePath As String, filePath As String, firstName() As String
Dim vStats As Variant
Dim currentDate As Date
Dim LastRow As Long, ArrayIndex1 As Long

Application.ScreenUpdating = False

With Sheet1 
    
        currentDate = .Range("H3").Value2
        LastRow = .Range("A1:A35").Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
        vStats = .Range("A1:E" & LastRow)
        
        myPath = .Range("k3").Value2
        
        LastRow = .Columns(1).Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
        If LastRow = 1 Then: MsgBox ("No People Selected in database."): Exit Sub
    
        wholeP/ath = myPath & "\" & Replace(currentDate, "/", "-") & "Reports"
        If Dir(wholePath, vbDirectory) = vbNullString Then MkDir (wholePath)
    

With Sheet2
        For ArrayIndex1 = LBound(vStats) To UBound(vStats)
        .Range("B2").Value2 = "Review - " & Replace(Format(currentDate, "dd/mm/yyyy"), "-", "/")
        .Range("c3").Value2 = vStats(ArrayIndex1, 1)
        .Range("c4").Value2 = vStats(ArrayIndex1, 2)
        .Range("c5").Value2 = vStats(ArrayIndex1, 3)
        .Range("c6").Value2 = vStats(ArrayIndex1, 4)
        .Range("c7").Value2 = vStats(ArrayIndex1, 5)
    
     
        filePath = wholePath & "\" & "CPAP Review - " & vStats(ArrayIndex1, 1) & " " & vStats(ArrayIndex1, 2) 
        firstName = Split(vStats(ArrayIndex1, 1), " ")
     
     'create PDF file
        Sheet2.ExportAsFixedFormat Type:=xlTypePDF, Filename:=filePath, Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
    
    Next ArrayIndex1
End With

End With
Application.ScreenUpdating = True

End Sub
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

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