Applying If

breakdance101

New Member
Joined
Jan 12, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I Have a sheet (not mine) that applies conditional Formatting based on if the following formula is true:
=AND(Z$28>=$EQ271,Z$28<=$ER271) - Each Cell refence refers to a date and colour the cells (the CF is applied too) Green (basically highlighting the dates items are moving from one department to another)
I would like to add some code that meant that when this condition is met the cells the CF is applied too, completes a Vlookup

so in my head the formula is
if (=AND(Z$28>=$EQ271,Z$28<=$ER271)=TRUE,VlookupA1,Sheetrange,2,false),""

I cannot however apply formula as the cells in question are data input cells

The Cell range this needs to be applied to is

=$AO$272:$AQ$272,$Z$271:$AQ$271,$Z$272:$AM$272,$Z$271:$AD$750,$Z$752:$EN$1152,$AF$271:$AJ$750,$AL$271:$AP$750,$Z$273:$AQ$750,$AR$271:$EN$750

I am very green at VBA but I'm getting used to it.

Any help is appreciated

Thanks
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
This appears to just be a formula rather than VBA. If that is true, then the following should work:
Excel Formula:
=if(AND(Z$28>=$EQ271,Z$28<=$ER271),Vlookup(A1,Sheetrange,2),"")
 
Upvote 0
Thanks - I was hoping to convert this formula to VBA as i can't add formula to the cells
 
Upvote 0
OK. Apologies for my confusion. I'm not clear on exactly where this lookup value will be placed on the sheet. I understand that you cannot paste my formula into the sheet, but if you could, which exact cells would it be placed in?

For a macro, you will need to have a clear definition of the logic. What cells are you looking at to make a decision, where are all the inputs for the Vlookup coming from, where are you placing the result? Since you aren't just copying and pasting like you do with an equation, you have to make the code smart enough to do this. It likely won't be a single equation, but a series of logical steps in order to get the desired result.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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