You bring up an interesting point about using CELL.
As an academic exercise, I think I'll play with and see if that might be a
viable approach.
--
Regards,
RD
--------------------------------------------------------------------
Please keep all correspondence within the Group, so all may benefit!
-------------------------------------------------------------------
Hi Ron,
As I read the OP, wouldn't the necessity of assigning a value to NumDec be
equal to simply formatting the Vlookup cell ?
Of course, feedback from the OP is needed, but I read the question as the
lookup list contained numeric data of varying decimal lengths, where perhaps
Row5 displayed 3 decimales and Row6 displayed 2 decimals, and the return to
the Vlookup formula (in one specific cell on Sheet1) was to reflect the
displayed format from Sheet2, which I believe the formula you suggested
couldn't do.
I obviously read the question differently <g>.
I thought he would have a separate cell to define NumDec.
If he is just interested in formatting significant digits as defined by the
entry in the LOOKUP Table, then all he would have to do is format the result
worksheet cells (where the VLOOKUP formula resides), as General.
However, if he wants to have trailing 0's based on how the data cell in the
table is formatted, (and not based on a separate cell defining NumDec), that
is
more difficult. I believe, depending on the details of how things are set
up,
that it could be done with the CELL worksheet function. This would assume
that
the data cell is formatted either as GENERAL or as a number with a
particular
number of decimal places (e.g. F5). So one could use that to produce the
format string within a TEXT worksheet function. There might be some issues
with recalculation, as changing a cell format does not trigger
recalculation,
but I think it could be done.
If that's the case, it'd probably be easiest to use VBA to actually change
the
format of the result cell.
Hopefully the OP will give us some guidance.
--ron