Get Cell Value

Vegas01

New Member
Joined
Jun 15, 2021
Messages
43
Office Version
  1. 2019
Platform
  1. Windows
Morning everyone

I am trying to get this formula to work and it does not seem to like when the cells are not together

=IFERROR(GetBlueCellValue(F2,H2,J2) * D2, 0)+IFERROR(GetBlueCellValue(G2,I2,K2), 0)

I need to pick Column F or H or J and multiple by Column D and add this together with G or I or K depending which one is blue.

I have the formula working with the cells are together. but not now it is in this format.

Thanks in advance
Nikki Liddell

1694394226227.png
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
What does "does not seem to like" mean? Are you perhaps getting a #VALUE! error?

What is GetBlueCellValue? Is it your macro? An add-in?

Is it set up to expect three arguments (or a variable number of arguments) like this? Or perhaps a single range?
 
Upvote 0
What does "does not seem to like" mean? Are you perhaps getting a #VALUE! error? - The formula is returning nil, when I evaluate the formula, it is giving an #value error on the following parts (F2,H2,J2), (G2,I2,K2)

What is GetBlueCellValue? Is it your macro? An add-in? - it is my VBA code and the current workbooks and is working on other pages where is use a range of columns like (F2:J2).

Is it set up to expect three arguments (or a variable number of arguments) like this? Or perhaps a single range? I was hoping that the formula can look up 3 separate columns and pick up the blue on.

I hope this helps, thanks in advance.
 
Upvote 0
If your Function is expecting a single range argument, and you're providing three ranges, it will necessarily error.

Perhaps you could modify your code along these lines:

VBA Code:
Function GetBlueCellValue(ParamArray rng()) As Variant

    Dim r1 As Variant, r2 As Variant
    Const MyBlue = 15773696
    
    For Each r1 In rng
        For Each r2 In r1
            If r2.Interior.Color = MyBlue Then GoTo Success
        Next r2
    Next r1

    GetBlueCellValue = CVErr(xlErrNA)
    Exit Function
    
Success:
    GetBlueCellValue = r2.Value

End Function

If you get stuck, please post your code.
 
Upvote 0

Forum statistics

Threads
1,215,095
Messages
6,123,073
Members
449,093
Latest member
ripvw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top