Thread: [Solved] VB Error
View Single Post
 
Old 04-03-2022, 03:30 PM
PomDave PomDave is offline Windows 10 Office 2010
Advanced Beginner
 
Join Date: Sep 2011
Location: Australia
Posts: 43
PomDave is on a distinguished road
Default VB Error

Hi All,

I'm trying to get my revised sheet to calculate prices and cannot see why it won't work.

My original had a macro with the following code that worked just fine:

Public Function DisneyStampListings(pRange1 As Range, pRange2 As Range) As Double
'Update 20140210
Application.Volatile
Dim rng As Range
Dim xTotal As Double
xTotal = 0
For Each rng In pRange1
If rng.Font.Color = pRange2.Font.Color Then
xTotal = xTotal + rng.Value
End If
Next
DisneyStampListings = xTotal
End Function

Now all I have done is copy the code over to my revised sheet and I get 'Expected end of statement' error which I can't resolve.

Public Fuction Disney_Stamp_Listings_2022 (pRange1 as Range, pRange2 as Range) As Double

Application.Volatile
Dim rng As Range
Dim xTotal As Double
xTotal = 0
For Each rng In Range1
If rng.Font.Color = p2Range.Font.Color Then
xTotal = xTotal + rng.Value
End If
Next
Disney_Stamp_Listings_2022 = xTotal
End Function

Any ideas
Reply With Quote