View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
OldRod OldRod is offline
external usenet poster
 
Posts: 1
Default Problem with a macro

I have a strange problem with some macros in Excel 2000.

The macros are all run from buttons on the same worksheet. Thi
worksheet allows the user to select a client name from a drop-dow
list, then builds a path/filename based on that selection.

Once the path/filename is built, the user can press another button t
actually load a file into Excel (it is an excel workbook). This macr
uses the code "Workbooks.Open m_file" to load the workbook, wher
m_file contains the path/filename generated earlier. This part work
fine.

Once the file is loaded, there is another button which runs a macro t
compare a list of names in the current workbook against a master lis
in another workbook. If there are names to be added, the macro insert
a row in the proper place and copys the information from the maste
list.

I am using "Selection.EntireRow.Insert" to insert the row (th
currently selected row is at the position where I want the ro
inserted).

This code causes a memory access violation and crashes Excel, bu
here's the strange part. This crash happens *only* if the file wa
loaded by clicking the "load" button mentioned earlier.

If the user selects the client name from the list (so the filename get
built), but then goes out and loads the file manually without clickin
the "Load file" button, then when the "Update Rows" button is clicked
there is no crash. The macro works fine and inserts rows as needed
often multiple times in the same run. Running the Update macro afte
the file has been loaded by clicking the Load button results in a fata
crash every single time the EntireRow.Insert code fires.

Anyone have any ideas why this could be happening

--
Message posted from http://www.ExcelForum.com