How to use Lookup in vba

largeselection

Active Member
Joined
Aug 4, 2008
Messages
358
I'm trying to set the background color of a square shape based on the color in another cell (the background is not set by conditional formatting).

So I have in the beginning:

Code:
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB =

I'm trying to figure out what to put after the =.

I have a set of data and an index. So in my index table it says if the value is between 50-60, then it should be in the "MID" bucket. I can do a lookup in the worksheet (next to the data) by =lookup(cell, index ranges, labels).

So I was thinking I could say after the = the cell which satisfies the lookup.Interior.Color (since I added the background to the "labels").

This is not working.

Here's what I tried:

Code:
.ForeColor.RGB = Range(Lookup(ActiveCell.Offset(0, 1).Value, Range("G28:G38"), Range("H28:H38")).Interior.Color

Thanks for any directions you can point me in
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Yes I have. However, this just tells me how to input the lookup formula into a cell on the worksheet. If I try to put this into the shape fill portion, it does not work.

As this:

Code:
With Selection.ShapeRange.Fill
        .Visible = msoTrue
        .ForeColor.RGB =FormulaR1C1 = "=LOOKUP(RC[-1],R28C7:R38C7,R28C8:R38C8)".interior.color
 
Upvote 0
Also, the answer to that formula is the value of the Bin that is in the cell. So the solution to that formula is "MID".

So that is likely why it isn't working because the formula answer is not the address of the cell.

So how can I indicate the address?
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

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