Hi, im fairly new to VBA and need help breaking down this code my predecessor created:
Sub fCopyAHTs()
'Copies the AHTs created to the Daily Tab for reference
Dim lngRow As Long, lngPasteRow As Long
Dim lngCol As Long, lngPasteCol As Long
Dim lngLoop As Long, lngColLoop As Long
Dim lngRowCol As Long, lngDays As Long
Dim strSearch(1) As String
Dim dblResult As Double
'hold variables
lngRow = fFindItem("Days in Month", True, "Build")
lngRowCol = fFindItem("Days in Month", False, "Build") - 1
lngDays = Build.Cells(lngRow, lngRowCol) - 1
lngRow = fFindItem("WeekDay", True, "Output") + 1
lngRowCol = fFindItem("WeekDay", False, "Output") - 1
strSearch(0) = "Working AHT"
strSearch(1) = "Budget AHT"
'loop through the two columns to be copied
For lngColLoop = 0 To 1
lngCol = fFindItem(strSearch(lngColLoop), False, "Output")
lngPasteCol = fFindItem(strSearch(lngColLoop), False, "Daily")
'loop through each day of the month
For lngLoop = 0 To lngDays
dblResult = Output.Cells(lngRow + lngLoop, lngCol)
lngPasteRow = Output.Cells(lngRow + lngLoop, lngRowCol)
Daily.Cells(lngPasteRow, lngPasteCol) = dblResult
Next
Next
End Sub
i cant figure out what fFindItem means and strSearch(0) but the rest i can just about manage to figure out what its doing. any help would be greatly appreciated
Sub fCopyAHTs()
'Copies the AHTs created to the Daily Tab for reference
Dim lngRow As Long, lngPasteRow As Long
Dim lngCol As Long, lngPasteCol As Long
Dim lngLoop As Long, lngColLoop As Long
Dim lngRowCol As Long, lngDays As Long
Dim strSearch(1) As String
Dim dblResult As Double
'hold variables
lngRow = fFindItem("Days in Month", True, "Build")
lngRowCol = fFindItem("Days in Month", False, "Build") - 1
lngDays = Build.Cells(lngRow, lngRowCol) - 1
lngRow = fFindItem("WeekDay", True, "Output") + 1
lngRowCol = fFindItem("WeekDay", False, "Output") - 1
strSearch(0) = "Working AHT"
strSearch(1) = "Budget AHT"
'loop through the two columns to be copied
For lngColLoop = 0 To 1
lngCol = fFindItem(strSearch(lngColLoop), False, "Output")
lngPasteCol = fFindItem(strSearch(lngColLoop), False, "Daily")
'loop through each day of the month
For lngLoop = 0 To lngDays
dblResult = Output.Cells(lngRow + lngLoop, lngCol)
lngPasteRow = Output.Cells(lngRow + lngLoop, lngRowCol)
Daily.Cells(lngPasteRow, lngPasteCol) = dblResult
Next
Next
End Sub
i cant figure out what fFindItem means and strSearch(0) but the rest i can just about manage to figure out what its doing. any help would be greatly appreciated