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.
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