Option Explicit
Public Const intLocation As Integer = 1
Public Const intZone As Integer = 2
Public Const intSite As Integer = 3
Public Const intID As Integer = 4
Public Const intLine As Integer = 5
Public Const intSwabber As Integer = 6
Public Const intDate As Integer = 7
Public Const intData As Integer = 8
Sub ProcessData()
Dim datStartProcessing As Date
datStartProcessing = Now()
Dim wks2019 As Worksheet
Dim wksData As Worksheet
Dim lngDataRow As Long
Dim lng2019Row As Long
Dim int2019Col As Integer
Dim int2019LastRow As Integer
Dim int2019LastCol As Integer
Dim intDateRow As Integer
Dim strLocation As String 'col 1
Dim strZone As String 'col 2
Dim strSite As String 'col 3
Dim strID As String 'col 4
Dim strLine As String 'col 5
Dim strSwabber As String 'col 6
Dim strResult As String 'store the swab result
Dim datSwabDate As Date 'need to pull the date from top
Dim intLocCol As Integer
Set wks2019 = ThisWorkbook.Worksheets("2019 Listeria")
Set wksData = ThisWorkbook.Worksheets("Data")
int2019LastRow = wks2019.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
int2019LastCol = 407 [highlight #FCE94F]'you may need to change this when your data changes[/highlight]
intDateRow = 4 'row of the date values
lngDataRow = 2 'starting row for data
lng2019Row = 6 'starting row for 2019 data
Application.ScreenUpdating = False
Application.Calculation = xlManual
Do Until strLocation = "DO NOT DELETE THIS ROW - USED FOR TALLY COUNT BELOW"
strLocation = wks2019.Cells(lng2019Row, intLocation)
If strLocation <> "DO NOT DELETE THIS ROW - USED FOR TALLY COUNT BELOW" Then
strZone = wks2019.Cells(lng2019Row, intZone)
strSite = wks2019.Cells(lng2019Row, intSite)
strID = wks2019.Cells(lng2019Row, intID)
strLine = wks2019.Cells(lng2019Row, intLine)
strSwabber = wks2019.Cells(lng2019Row, intLine)
Debug.Print "lng2019Row: " & lng2019Row
For int2019Col = 7 To int2019LastCol
datSwabDate = wks2019.Cells(intDateRow, int2019Col)
wksData.Cells(lngDataRow, intLocation) = strLocation
wksData.Cells(lngDataRow, intZone) = strZone
wksData.Cells(lngDataRow, intSite) = strSite
wksData.Cells(lngDataRow, intID) = strID
wksData.Cells(lngDataRow, intLine) = strLine
wksData.Cells(lngDataRow, intSwabber) = strSwabber
wksData.Cells(lngDataRow, intDate) = datSwabDate
wksData.Cells(lngDataRow, intData) = wks2019.Cells(lng2019Row, int2019Col)
lngDataRow = lngDataRow + 1
Next
End If
lng2019Row = lng2019Row + 1
Loop
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
Debug.Print "Seconds: " & DateDiff("s", datStartProcessing, Now())
End Sub