Highlight values based on a range of values. Excel - vba

In excel, in a range of cells (say A1 to A100) highlight only values that contain any of the values in a specified range (say A101 to 150). Duplicates among A1 to A100 SHOULD NOT be highlighted. Anybody has a solution?

Give this a try. Select B2:B15893 > go to conditional formatting 'Use a formula to determine which cells to format' > enter formula =AND(COUNTIF($B$2:$B$15893,B2)>1,COUNTIF($B$15895:$B$15924,B2)>0) > Format as Yellow fill > Click OK.
The first logic test in the AND() function tests if the value is a duplicate in range $B$2:$B$15893 and the second test if the value also exists in the range of values at the bottom. If both logic tests are true then the value will be highlighted.
Here is a screenshot of a smaller example. Hope this helps!

Related

Conditional Formatting (If/when)

Ok so I want a row to highlight red when the date in cell C1 is more than the cell in B1, but only if this is a difference of two months or less. I am sorry, I don't know how to embed a dummy spreadsheet. So for example, if B1 (clinic appointment due date) is Sep-17 and C1 (physical checks due date) is Oct-17, I want this row to highlight. If C1 is Dec-17, I don't want the row to highlight because this is more than two months from Sep-17.
Edited based on your new description, using Column A to represent Clinic Appointment Date and Column B to represent Physical Checks Due Date.
Use a rule based on DAYS().
Click on cell A1
Choose New rule from the Conditional Formatting menu.
Choose Use a formula to determine which cells to format
In Format values where this formula is true:, use the below formula:
=DAYS(B1, A1) < 60
Set up the formatting you want to use to highlight the cells. In the image below, I've set the ones that meet your requirements for highlighting to appear in red, and applied it to the first two rows in Column A (A1 and A2):
Here's the sheet with sample data in two rows, showing the conditional formatting working as requested:

Excel VBA checks cells in certain order before returning a value from one of them in another cell

I have a row of 4 cells that contain either 3 0's and a number, or two numbers and 2 0's. I need excel to check the cells from left to right and if a cell contains a 0 move on to the next cell until it finds a number and then return that number in cell 5. Any help would be grately appreciated!!
My test Data
enter image description here
Enter this formula in Column E,
=IF(A1=0,IF(B1=0,IF(C1=0,IF(D1=0,"All are Zeroes",D1),C1),B1),A1)
Use this formula:
=INDEX($A1:$D1,AGGREGATE(15,6,COLUMN($A1:$D1)/($A1:$D1<>0),1))

Using conditional formatting in excel, I want to highlight the value in the range if matches with value given in cell B1

Using conditional formatting in excel, I want to highlight the value in the range if matches with value given in cell B1.
Assuming the relevant range is as in example, select A1:A10 and HOME > Styles - Conditional Formatting, New Rule..., Use a formula to determine which cells to format and Format values where this formula is true::
=A1=B$1
Format..., select choice of formatting, OK, OK.

macro code to show much input range in dropdown list

I need a macro code to display more than one input range in dropodown list that I created in sheet2 via the form control.
I want an event with IF logic, where I have many names range from another sheet with the name eg: DaftarA (in sheet1 C1:C30), DaftarB (in sheet1 C40:C60), DaftarC (in sheet1 C70:C90).
How to write macros if the value in sheet2 C1 1, the dropdown list will display the input range of (name range) DaftarA, if the value is 2 then displayed in the dropdown list is (name range) dDftarB and so on ..
is there anything that can help? thank you
You can define a name for the list through the offset formula and use that name as a list for data validation drop down box.
=OFFSET(Sheet1!$B$1,Sheet1!$F$1,0,Sheet1!$E$1,1)
where cell B1 is top of the list, cell F1 shows how much you offset down, cell E1 will control the length of the list. It will work however only if your multiple ranges are on the same sheet and in the same column
It will also work if you define a name with the following formula
=IF(Sheet1!$F$1=1,test1,IF(Sheet1!$F$1=2,test2,IF(Sheet1!$F$1=3,test3)))
However in this case you need to name each particular range you want(like in this example test1, test2, test3) and of course you can't put too many nested formulas as it will get messy.

Excel VBA - selecting the range from first row to the last row

I have a problem with VBA code. I have a sheet with a lot of data around the cells I want. I need to select data in column F, but the position of the first and last cells between the range is to be selected is changing up and down. I created the non empty cells in row X where there is no data do the LastRow function has any refernece but now I dont know how to select the first row
thx for help
If F1 is empty, this selects the first cell with data in the F column
Worksheets("Sheet1").Range("F1").End(xlDown).Select
If F1 may be non-empty you can add a check to see whether it contains text.