-5

This seems like such an easy thing but I can't seem to work it out.

All I am looking to do is have a dynamic last column based on the last active column in the row above.

I have a similar code for finding the last active row

 LastCell = Sheets("CALCULATIONS").Range("A20000").End(xlUp).Row
 Sheets("CALCULATIONS").Range("A2:A" & LastCell).Copy

Now I am trying to work out a horizontal version.

All I want to do is find the last active column based on values in row 15 in CALCULATIONS then drag the array formula that already in A16 across to [?]16 (? being the last column from row 15)

I feel like the solution is right in front of me but I've been drawing blanks!

Any help would be great!!

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
Jerremy Leedham
  • 97
  • 4
  • 13
  • 1
    Possible duplicate of https://stackoverflow.com/questions/11926972/excel-vba-finding-the-last-column-with-data – Maddy Sep 07 '18 at 04:22

1 Answers1

0

Try,

dim lc as long

with workSheets("CALCULATIONS")
    lc = .cells(15, .columns.count).end(xltoleft).column
    .range(.cells(16, "A"), .cells(16, lc)).formula = .cells(16, "A").formula
    'alternate method
    '.range(.cells(16, "A"), .cells(16, lc)).fillright
end with