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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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,627
Messages
6,120,610
Members
448,973
Latest member
ChristineC

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