Problem with macro inserting row into advanced filter

vanb

New Member
Joined
Feb 21, 2009
Messages
1
I am new to macros and VB, so I may be missing something basic. I am having this problem:

I have a workbook with many worksheets, all of which refer back to Sheet1 such that each row on each sheet should match up (represent the same item). I created a macro to insert a row in each sheet at the same row number. It works fine for most sheets. However, the sheets which have advanced filters applied to them do not insert the line. I do not receive any error messages. I am inserting rows by copying a row and inserting it over itself so that the adjacent formulas are copied.

One notable exception: If the row where the new row is being inserted is not hidden on a sheet, it does properly insert.

Is the best way to accomplish this to have the macro turn off the advanced filter on each sheet, insert the row, then reapply the advanced filter? Any suggestions for such code?

Thanks.
 

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
If all else fails, that's what I would do, it shouldn't take much time unless you have thousands of worksheets to do this with!
 
Upvote 0
If you have filtered few worksheets then just do this before your macro
Code:
Sub test()
Dim ws As Worksheet
On Error Resume Next
For Each ws In Sheets
    ws.AutoFilterMode = False
    ws.ShowAllData
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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