RE: Format of Cell with Array Formula - Using VBA

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi, Patrick. It is:
{=VLOOKUP(TRIM($B5),TRIM($B$26:$D$41),3,FALSE)}

"Patrick Molloy" wrote:

what does the formula text itself look like?
=TRIM ( ????)


"Paige" wrote:

I have a form where the user selects a cell for a specific formula via
refedit, then selects whether he wants the TRIM function added to the formula
or not. Just prior to inserting the formula, I determine the format of
another cell and apply it to the cell that will contain the new formula. If
TRIM is not part of the formula, everything works fine and the cell with the
new formula has the correct format. However, if I add TRIM (and the formula
is now an array formula), when it is put into the cell, the 'underlying'
format is changed to TEXT, even though the displayed format via Format |
Cells is Currency (which is what it should be), and I can’t change it
regardless of what I do. I've tried everything to correct this and have no
idea what I'm doing wrong. Any ideas where I’m going wrong?????

The code:
Dim ColIndexNumberCell As Range
Dim ColIndexNumberCellAddress As String
Dim LFormulaCellAddress As String

This is the code that I use to format the cell where the new formula will go:
Set ColIndexNumberCell = Range(SelectColIndexRefEdit.Text)
ColIndexNumberCellAddress = ColIndexNumberCell.Address(False, True)
With ActiveCell
.NumberFormat = Range(ColIndexNumberCellAddress).NumberFormat
End with

Then I enter the formula WITHOUT trim (and thus not an array):
Range(LFormulaCellAddress).Formula = Me.LFormula.Caption

Then if the user selected TRIM, I take the original formula and change it to
an array:
Range(LFormulaCellAddress).FormulaArray = Range(LFormulaCellAddress).Formula

.



Relevant Pages

  • RE: Format of Cell with Array Formula - Using VBA
    ... another cell and apply it to the cell that will contain the new formula. ... TRIM is not part of the formula, everything works fine and the cell with the ... new formula has the correct format. ... Dim ColIndexNumberCell As Range ...
    (microsoft.public.excel.programming)
  • Format of Cell with Array Formula - Using VBA
    ... another cell and apply it to the cell that will contain the new formula. ... TRIM is not part of the formula, everything works fine and the cell with the ... new formula has the correct format. ... Dim ColIndexNumberCell As Range ...
    (microsoft.public.excel.programming)
  • Re: Funtions Not Taking Effect
    ... What are the possible reasons for this?- Hide quoted text - ... of " F012345 " formatted as text to a blank cell formatted as text. ... When I changed the format of the blank cell to general, the trim ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Funtions Not Taking Effect
    ... Excel will assume that the format of the first cell you refer to in a ... formula is the format you want to use in the cell with the formula - ... When I changed the format of the blank cell to general, the trim ...
    (microsoft.public.excel.worksheet.functions)
  • Re: questions regarding ranges
    ... You could select a single cell ... Record a macro if you want to mechanize it. ... Set myRng = Nothing ... There's a difference between VBA's trim and Excel's Trim. ...
    (microsoft.public.excel.misc)