Consulting

Results 1 to 4 of 4

Thread: Solved: Array Not Working

  1. #1

    Solved: Array Not Working

    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?

    [VBA]Dim lRow As Long

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

    Range("D2" & 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[/VBA]
    Feedback is the best way for me to learn


    Follow the Armies

  2. #2
    VBAX Regular HaHoBe's Avatar
    Joined
    Aug 2004
    Location
    Hamburg
    Posts
    89
    Location
    Hi, fredlo2010,

    try

    [vba]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[/vba] Ciao,
    Holger

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [VBA]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[/VBA]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    Thanks a lot guys,

    Both solutions worked perfectly

    What was I doing wrong?
    Feedback is the best way for me to learn


    Follow the Armies

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •