lookup format

R

Rach

Hi

I'm doing a vlookup but i also want to maintain the formatting of the cell
that has the data that im looking up e.g. highlighted in blue.

Is there a way to do this?
 
T

Thomas [PBD]

Rach,

The best that I could dally up was the return the number formatting of a
VLookup, not necessarily the borders/fill/text color.

This would require you to add a User Defined Function to your document.
Press Alt+F11>Insert>Module. In the module add:

Function GetFormat(Cell as Range) as String
GetFormat = cell.NumberFormat
End Function

and for your Vlookup, you will need to add:

=TEXT(VLOOKUP(<Cell>,<Array>,<Column>,<T/F>),GetFormat(<Cell>))

So, if B1 is the value you wish to return, from array A1:B4, lookup on C1,
then:

=TEXT(VLOOKUP(C1,$A$1:$B$4,2,FALSE),GetFormat(B1))
 
Top