L
L. Howard
I am looking in column A of the sheets for a name and each name will have a value next to it in B. The name may appear multiple times per sheet,
so find next or all is necessary for a total across all sheets.
Assume In code below all is Dimmed correctly, how to add all the varOut's as they are found in column A .Offset(, 1) of each sheet in array.
Can the same code lines be used for constants and values from formulas or is a PasteSpecial.Values needed?
Once I have the correct code lines to add the varOut's I assume I can also use that code with FIND as the search method also?
Not stuck on this code if it can be quicker or more efficient.
Thanks.
Howard
MyArr = Array("Sheet2", "Sheet3", "Sheet4")
For i = LBound(MyArr) To UBound(MyArr)
With Sheets(MyArr(i))
lr = .Cells(.Rows.Count, 1).End(xlUp).Row
Set rngA = .Range("A1:A" & lr)
For Each c In rngA
If c = myName Then
varOut = c.Offset(, 1)
'/ add all the varOut's
'/ together as they are found
'/ across all the sheets
'/ and display total in msgbox
End If
Next 'c
End With
Next 'i
MsgBox "The total for " & myName & " is: " & varOut
so find next or all is necessary for a total across all sheets.
Assume In code below all is Dimmed correctly, how to add all the varOut's as they are found in column A .Offset(, 1) of each sheet in array.
Can the same code lines be used for constants and values from formulas or is a PasteSpecial.Values needed?
Once I have the correct code lines to add the varOut's I assume I can also use that code with FIND as the search method also?
Not stuck on this code if it can be quicker or more efficient.
Thanks.
Howard
MyArr = Array("Sheet2", "Sheet3", "Sheet4")
For i = LBound(MyArr) To UBound(MyArr)
With Sheets(MyArr(i))
lr = .Cells(.Rows.Count, 1).End(xlUp).Row
Set rngA = .Range("A1:A" & lr)
For Each c In rngA
If c = myName Then
varOut = c.Offset(, 1)
'/ add all the varOut's
'/ together as they are found
'/ across all the sheets
'/ and display total in msgbox
End If
Next 'c
End With
Next 'i
MsgBox "The total for " & myName & " is: " & varOut