PDA

View Full Version : Solved: Array Not Working



fredlo2010
08-02-2012, 09:36 AM
Hi guys,

I am trying to populating values in cells using an array but I can't do it.

What's wrong with my code?

Dim lRow As Long

lRow = Sheets("Checkup").Cells(Rows.Count, 1).End(xlUp).Row

Range("D2:D" & lRow).FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-3],Reference,5,FALSE),0)"
Range("E2:E" & lRow).Value = 0.8 / 28
Range("F2:F" & lRow).FormulaR1C1 = "=RC[-3]*RC[-2]*RC[-1]"

'ADD THE TOTALS

With Range("E" & lRow).Offset(2, 0).Resize(3, 1)
.Value = Array("Total Sq. Ft.:", "Monthly Price:", "Total Amount:")
.Font.Bold = True
.HorizontalAlignment = xlRight
End With

HaHoBe
08-02-2012, 10:00 AM
Hi, fredlo2010,

try

With Range("E" & lRow).Offset(2, 0).Resize(3, 1)
.Value = WorksheetFunction.Transpose(Array("Total Sq. Ft.:", "Monthly Price:", "Total Amount:"))
.Font.Bold = True
.HorizontalAlignment = xlRight
End With Ciao,
Holger

Bob Phillips
08-02-2012, 10:08 AM
With Range("E" & lRow).Offset(2, 0).Resize(3, 1)
.Value = [{"Total Sq. Ft.:"; "Monthly Price:"; "Total Amount:"}]
.Font.Bold = True
.HorizontalAlignment = xlRight
End With

fredlo2010
08-02-2012, 10:39 AM
Thanks a lot guys,

Both solutions worked perfectly :)

What was I doing wrong?