Hi guys,
Firstly let me point out that my programming skill is pretty basic so I may have made some rookie mistakes in my code below.
I have a spreadsheet which I will be adding to over time. I need a macro that will look for the last 10 rows and then pull together a summary table based on data from several of the columns on each of those rows.
I've tried to go about this by using an array. The array will always be the same size (it will always be 10 by 11, i.e. EngineArray(10,11)-basically the same size as my summary table). I've also set Option Base 1.
What I’ve got so far is below. It isn’t working properly though. To start with I was getting ‘type mismatch errors’. Now instead of reading the numbers from the selected cells into the array, it just changes all the cells I’m trying to read from to ‘TRUE’????!
Can anyone point out what I’ve done wrong? Like I said, I’m pretty new to all this so I’m sure it’s probably something trivial. I’ve not included the pasting part of the macro because I think it’s the part below which is causing the problems.
Sub LastTenEngines()
Dim EngineArray(10, 11) As Long
Dim i As Integer
For i = 0 To 9
Range("F9").End(xlDown).Select 'Find the last row
ActiveCell = ActiveCell.Offset(-i, 0).Select 'Get onto the row with data
ActiveCell = ActiveCell.Offset(0, -3).Select
EngineArray(i + 1, 1) = ActiveCell.Value
ActiveCell = ActiveCell.Offset(0, 55).Select
EngineArray(i + 1, 2) = ActiveCell.Value
ActiveCell = ActiveCell.Offset(0, 2).Select
EngineArray(i + 1, 3) = ActiveCell.Value
ActiveCell = ActiveCell.Offset(0, 2).Select
EngineArray(i + 1, 4) = ActiveCell.Value
ActiveCell = ActiveCell.Offset(0, 2).Select
EngineArray(i + 1, 5) = ActiveCell.Value
ActiveCell = ActiveCell.Offset(0, 2).Select
EngineArray(i + 1, 6) = ActiveCell.Value
ActiveCell = ActiveCell.Offset(0, 2).Select
EngineArray(i + 1, 7) = ActiveCell.Value
ActiveCell = ActiveCell.Offset(0, 2).Select
EngineArray(i + 1, 8) = ActiveCell.Value
ActiveCell = ActiveCell.Offset(0, 2).Select
EngineArray(i + 1, 9) = ActiveCell.Value
ActiveCell = ActiveCell.Offset(0, 2).Select
EngineArray(i + 1, 10) = ActiveCell.Value
ActiveCell = ActiveCell.Offset(0, 2).Select
EngineArray(i + 1, 11) = ActiveCell.Value
Next i
Thanks in advance,
Chris
Bookmarks