![]() |
Trying to insert rows in a Macro
Hello, all:
I'm trying to record a macro that will autofilter a selection, select all visible rows, and insert new rows. Here is the section of the code generated by the Macro Recorder: Cells.Select Selection.AutoFilter Selection.AutoFilter Field:=2, Criteria1:="1" Rows("2:2234").Select Selection.SpecialCells(xlCellTypeVisible).Select Selection.Insert Shift:=xlDown It always hangs up on the last line, with the following message: Run-time error '1004': Insert method of Range class failed I can't figure out why it isn't working; any suggestions or help are greatly appreciated. Thanks! |
Trying to insert rows in a Macro
I think I'd put this in before the line with the error.
Debug.print selection.address What does it tell you? -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "jerryb123" wrote: Hello, all: I'm trying to record a macro that will autofilter a selection, select all visible rows, and insert new rows. Here is the section of the code generated by the Macro Recorder: Cells.Select Selection.AutoFilter Selection.AutoFilter Field:=2, Criteria1:="1" Rows("2:2234").Select Selection.SpecialCells(xlCellTypeVisible).Select Selection.Insert Shift:=xlDown It always hangs up on the last line, with the following message: Run-time error '1004': Insert method of Range class failed I can't figure out why it isn't working; any suggestions or help are greatly appreciated. Thanks! |
Trying to insert rows in a Macro
It doesn't seem to change anything that happens--I still get the same error
message. Does this generate an error report or something? "Barb Reinhardt" wrote: I think I'd put this in before the line with the error. Debug.print selection.address What does it tell you? -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "jerryb123" wrote: Hello, all: I'm trying to record a macro that will autofilter a selection, select all visible rows, and insert new rows. Here is the section of the code generated by the Macro Recorder: Cells.Select Selection.AutoFilter Selection.AutoFilter Field:=2, Criteria1:="1" Rows("2:2234").Select Selection.SpecialCells(xlCellTypeVisible).Select Selection.Insert Shift:=xlDown It always hangs up on the last line, with the following message: Run-time error '1004': Insert method of Range class failed I can't figure out why it isn't working; any suggestions or help are greatly appreciated. Thanks! |
Trying to insert rows in a Macro
Type CTRL G to go to your IMMEDIATE window. It should show an address of
some kind. -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "jerryb123" wrote: It doesn't seem to change anything that happens--I still get the same error message. Does this generate an error report or something? "Barb Reinhardt" wrote: I think I'd put this in before the line with the error. Debug.print selection.address What does it tell you? -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "jerryb123" wrote: Hello, all: I'm trying to record a macro that will autofilter a selection, select all visible rows, and insert new rows. Here is the section of the code generated by the Macro Recorder: Cells.Select Selection.AutoFilter Selection.AutoFilter Field:=2, Criteria1:="1" Rows("2:2234").Select Selection.SpecialCells(xlCellTypeVisible).Select Selection.Insert Shift:=xlDown It always hangs up on the last line, with the following message: Run-time error '1004': Insert method of Range class failed I can't figure out why it isn't working; any suggestions or help are greatly appreciated. Thanks! |
Trying to insert rows in a Macro
It says Go to:
$A$2 $A$1 "Barb Reinhardt" wrote: Type CTRL G to go to your IMMEDIATE window. It should show an address of some kind. -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "jerryb123" wrote: It doesn't seem to change anything that happens--I still get the same error message. Does this generate an error report or something? "Barb Reinhardt" wrote: I think I'd put this in before the line with the error. Debug.print selection.address What does it tell you? -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "jerryb123" wrote: Hello, all: I'm trying to record a macro that will autofilter a selection, select all visible rows, and insert new rows. Here is the section of the code generated by the Macro Recorder: Cells.Select Selection.AutoFilter Selection.AutoFilter Field:=2, Criteria1:="1" Rows("2:2234").Select Selection.SpecialCells(xlCellTypeVisible).Select Selection.Insert Shift:=xlDown It always hangs up on the last line, with the following message: Run-time error '1004': Insert method of Range class failed I can't figure out why it isn't working; any suggestions or help are greatly appreciated. Thanks! |
Trying to insert rows in a Macro
Actuall, that window was in Excel. In Visual Basic, the Immediate window reads:
$2:$2,$17:$17,$19:$19,$30:$30,$58:$58,$67:$67,$80: $80,$82:$82,$84:$84,$101:$101,$184:$2234 These are the visible rows where I want to insert rows. "jerryb123" wrote: It says Go to: $A$2 $A$1 "Barb Reinhardt" wrote: Type CTRL G to go to your IMMEDIATE window. It should show an address of some kind. -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "jerryb123" wrote: It doesn't seem to change anything that happens--I still get the same error message. Does this generate an error report or something? "Barb Reinhardt" wrote: I think I'd put this in before the line with the error. Debug.print selection.address What does it tell you? -- HTH, Barb Reinhardt If this post was helpful to you, please click YES below. "jerryb123" wrote: Hello, all: I'm trying to record a macro that will autofilter a selection, select all visible rows, and insert new rows. Here is the section of the code generated by the Macro Recorder: Cells.Select Selection.AutoFilter Selection.AutoFilter Field:=2, Criteria1:="1" Rows("2:2234").Select Selection.SpecialCells(xlCellTypeVisible).Select Selection.Insert Shift:=xlDown It always hangs up on the last line, with the following message: Run-time error '1004': Insert method of Range class failed I can't figure out why it isn't working; any suggestions or help are greatly appreciated. Thanks! |
All times are GMT +1. The time now is 02:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com