Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.
Public Function SumVlookups(ByVal Lookupvalue As Single, ByVal RangeToSum As Range) As Single
Dim ArrayStr As Range
For Each ArrayStr In RangeToSum
If Not IsError(Application.VLookup(Lookupvalue, Evaluate(ArrayStr.Value), 1, False)) Then SumVlookups = SumVlookups + Application.VLookup(Lookupvalue, Evaluate(ArrayStr.Value), 2, False)
Next ArrayStr
End Function
Sub testEnumeration()
Dim r As Range
For Each r In Range("A1:B30")
Debug.Print r.Address
Next r
End Sub
Dim r as range
Dim rng as range 'could be Object or Variant, but well defined as Range
Set rng = Range("A1:B500")
For Each r in rng
'do something
next r
>>so is the For Each looking for a local range from which to use the enumerated integers and so the name used must have been dimensioned, or is it implied that the characters used are a Range class? What if the name is dimensioned as something else? crunch?Dim r as range
Dim rng as range 'could be Object or Variant, but well defined as Range
Set rng = Range("A1:B500")
For Each r in rng
'do something with r.value 'not r, but r.value (however, FYI .Value is the default property)
next r
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
Multiple Open Excel Spreadsheets | 12 | 39 | |
Data in Rows to be converted into single row | 9 | 39 | |
Calculate number of nights between two dates | 5 | 18 | |
If help | 9 | 41 |
Join the community of 500,000 technology professionals and ask your questions.