FormulaR1C1

M

Marc

I have vfp code like below
loExcelSession.Cells(1,11).FormulaR1C1 =
ALLTRIM(STR(loExcelSession.Cells(1,11).Value))
Is there anyway to update the entire column at once?
 
P

Patrick Molloy

dim target as Range
SET target = Range("{your range here}")
with target
.FormulaR1C1 = "{your formula here}"
end with
 
B

Bob Phillips

Try this

With loExcelSession

LastRow = .Cells(.Rows.Count, 11).End(xlUp).Row
.Columns(12).Insert
.Cells(1,12).Resize(LastRow).Formula = "=TRIM(A11)"
.Cells(1,12).Resize(LastRow).Value = .Cells(1,12).Resize(LastRow).Value
.Columns(11).Delete
End With
 
Top