kingleviathan
Board Regular
- Joined
- Aug 23, 2010
- Messages
- 57
Hi Excel Gurus
Would anyone be able to advise what I am doing wrong with my code or a better way of doing it? I greatly appreciate you help
i have this code -
range("A" & ?).select
Selection.ListObject.ListRows(?).Delete
I need to use this code as entirerow.delete or similar code will not work
In column AA - starting at cell 1 - i have cells with numbers ie AA1 has 3 AA2 has 5, AA3 has 20
So starting with the laste used cell (ie. in my example it is AA3) - I need 20 inserted into the (?)
The process is then repeated for AA2. So AA2 has 5 inserted into the (?) in my code.
Ditto for AA1
Note: it is very possible that in some cases there may be no entries in AA..
Also - It is unknown what will be the cell used in AA a row count for last cell in AA may be required.
Would anyone be able to advise what I am doing wrong with my code or a better way of doing it? I greatly appreciate you help
i have this code -
range("A" & ?).select
Selection.ListObject.ListRows(?).Delete
I need to use this code as entirerow.delete or similar code will not work
In column AA - starting at cell 1 - i have cells with numbers ie AA1 has 3 AA2 has 5, AA3 has 20
So starting with the laste used cell (ie. in my example it is AA3) - I need 20 inserted into the (?)
The process is then repeated for AA2. So AA2 has 5 inserted into the (?) in my code.
Ditto for AA1
Note: it is very possible that in some cases there may be no entries in AA..
Also - It is unknown what will be the cell used in AA a row count for last cell in AA may be required.
Code:
Sub Test()
Dim r as range
Dim LastRow as long
Do while ("AA1") <> "" 'if first cell is blank then
LastRow = Cells(Rows.Count, "AA").End(xlUp).Row 'Find last cell in AA
set r = cells.value("AA" & LastRow) 'make r the value of last cell in AA
range("A" & r).select 'Select cell of row to be deleted in A (not AA)
Selection.ListObject.ListRows(r).Delete 'Delete that row
r.delete 'Delete last cell used in AA
loop
End sub