Macro anger!!

Audiojoe

Active Member
Joined
Feb 20, 2002
Messages
285
How do I write a macro to do the following:

Suppose the active cell is A1. I need to delete rows - 1,2,3,6,10,12,13 and 14.

But I need to it be relative to where the active cell is. I've tried recording it but it keeps going back to A1 and doing the macro again. I need it to perform the task starting wherever the active cell is

Any ideas?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi

Try:

ActiveCell.Range("A1,A2,A3,A6,A10,A12,A13,A14").EntireRow.Delete

It's relative to the activecell
 
Upvote 0
Something like this should work, the row is offset based upon the activecell. I'm not sure if I recommend doing this since you can irreversibly delete data by mistake using "Activecell". Anyway, here's what you asked for:

<pre>
Option Base 1

Public Sub DeleteRows()

Dim iArray(8) As Integer
Dim i As Integer

iArray(1) = 1
iArray(2) = 2
iArray(3) = 3
iArray(4) = 6
iArray(5) = 10
iArray(6) = 12
iArray(7) = 13
iArray(8) = 14

For i = 8 To 1 Step -1 'step backwards since we're deleting rows
ActiveCell.Offset(iArray(i), 0).Rows.Delete
Next

End Sub</pre>
 
Upvote 0

Forum statistics

Threads
1,214,391
Messages
6,119,244
Members
448,879
Latest member
VanGirl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top