PDA

View Full Version : Select Cells based on values in another cell



infinity
04-03-2015, 08:16 AM
Good morning VBA Experts,

I am trying to select a range of cells based on if there is a value in another range of cells. The first thing is, in External ID column I have formula's that return blank through if/and/or statements and I only want to select the range if there is a value in "MPN" which does not have formulas so using Range(Selection, Selection.End(xlDown)).Select will not work because it selects even the cells that have returned <blank> in "External ID" column, this would be a continuous range. T

he second thing I need to do, which is a separate part of the VBA code, I need to select the cells in "External ID" column if there is <blank> in "Recreated Item" column. This would be a non-continuous range because only some items have a value in "Recreated Item" column.



MPN

EXTERNAL ID

Matrix Child?

Recreated Item



PS49051

PS49051-PRI


49051-PRI



PS43211

PS43211-PRI


43211-PRI



40261

40261-PRI





284

284-PRI





285

285-PRI





241

241-PRI





242

242-PRI





PS1175

PS1175-PRI


1175-PRI



PS1176

PS1176-PRI


1176-PRI



PS1193

PS1193-PRI


1193-PRI



PS1184

PS1184-PRI


1184-PRI



PS1185

PS1185-PRI


1185-PRI



PS1186

PS1186-PRI


1186-PRI



PS1244

PS1244-PRI


1244-PRI

Yongle
04-04-2015, 11:36 AM
How about a combination of 2 if statements inside a for loop searching through column MPN?
replace c with the column number for MPN
The first line eliminates cells with formula, the second cells which are blank



if cells(i, c).HasFormula = False then
If cells(i,c).value <> "" then
Untested - away from PC this week


The sccond line could also help you sort your other issue

Yongle
04-07-2015, 04:25 AM
Did above suggestion allow you to solve your problem?