Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Excel Script Problem?
I had earlier posted a problem about an Excel script created in Excel 2000, bombing out in Excel 2003, but failed to write the error message. Here it is:
Runtime Error 1004
Insert method of range class failed
Does anyone know what this means?
When you debug the error, it goes to the spot in the script listed below. In the debugger, the last row of this text is highlighted in yellow.
Dim targetRow As Integer
targetRow = getSubtotalRow()
'Insert a blank row above subtotal.
Sheets("TimeSheet").Range("A" & targetRow).EntireRow.Insert
I've tried using the list feature in 2003, as one person suggested (which works nicely) but I don't know how to edit the script.
1. Not everyone is using 2003, some are still stuck on 2000.
2. Not being familiar with code, didn't want to delete the wrong thing. The entire thing (to me anyway) is quite complicated as it takes the excel in one format and converts it into another format so that it can then be converted into a prn file, converted once more and then imported into the company's legacy accounting system (yes it's converted 3x, in essence).
will try your suggestions when I get to the office on Monday. Thanks for all the help.
2 Answers
- TimLv 41 decade agoFavorite Answer
EDIT: Now, I understand why the list won't work for you. The whole process does sound convoluted, and there must be an easier way.
Did you try the MsgBox code that I mentioned?
You can contact me through my Website if you'd like. (Please, only this questioner.)
-----------------------------------------------------------------
Why don't you use the List method if it works well? Then you can just get rid of the VBA code that is causing problems.
Anyway, we don't have the getSubtotalRow() function, so that make it hard to debug. You code works fine for me if I put a number (e.g., 42) in place of getSubtotalRow(). That means that the line that you think is causing the error probably isn't.
My suspicion is that that function is returning something other than the expected integer. That would cause an error, and the error would probably differ depending on what it is returning.
Try adding the following code right above the Sheets("TimeSheet")... code:
MsgBox "The targetRow variable is " & targetRow
and see what it says. It should display a message box that says something like "The targetRow variable is 42". You need to see what the number (or whatever) is at the end of that message (42 in my example).
Tim
- ?Lv 45 years ago
i might think of in the 2d macro that the shrink action isn't ordinary with the aid of fact the rows series merchandise in the 2d macro belongs to the energetic sheet, yet is then calls an merchandise that may not lie on the comparable sheet: Rows(rng(one million).Row).shrink ? i might merely use the variety.advancedfilter approach to do the replica, and then delete the suited rows.