ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   lookup format (https://www.excelbanter.com/excel-discussion-misc-queries/204855-lookup-format.html)

Rach[_2_]

lookup format
 
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?

Thomas [PBD]

lookup format
 
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+F11InsertModule. 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))

--
--Thomas [PBD]
Working hard to make working easy.


"Rach" wrote:

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?



All times are GMT +1. The time now is 11:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com