I’m sorry to be such a pain lately… I’m trying to write the following procedure and I’m not sure what the syntax for the commented lines would be… Can someone help me?… (Please let me know if you know of a better way to do this too…)
Sub GetTotals()
Dim rw As Integer, rwNew As Integer
Dim mySheet As Object, dirSheet As Object, tieinSheet As Object
Set mySheet = Worksheets(“ByDeptandProd”)
Set dirSheet = Worksheets(“DIRByDept”)
Set tieinSheet = Worksheets(“TieIn”)
rwNew = 2
For rw = 2 To 2000 ‘for each of the rows in Canadian Sheet
If Right(Trim(mySheet.Cells(rw, 2).Value), 5) = “Total” Then
tieinSheet.Cells(rwNew, 1) = mySheet.Cells(rw, 1)
tieinSheet.Cells(rwNew, 2) = mySheet.Cells(rw, 2)
tieinSheet.Cells(rwNew, 3) = mySheet.Cells(rw, 7)
‘Find matching value in column 2 of DirByDept sheet (ie… “001 Total” row on both sheets…)
‘If no match then
‘tieinSheet.Cells(rwNew,4) = 0
‘Else (there is a match)
‘tieinSheet.Cells(rwNew,4) = DirByDept row where the match is, column 8
‘End If
rwNew = rwNew + 1
End If
Next rw
Set mySheet = Nothing
Set dirSheet = Nothing
Set tieinSheet = Nothing
End Sub