View Full Version : Cut and paste a macro?
SC-tbfd
Mar 14, 2008, 12:16 PM
I'm trying to create a spreadsheet based on an older version that has a macro. When open both workbooks, cut and paste the old to the new, open vb editor and drag the forms folder and modules folder to the new workbook the macro runs but is broken (it works in the old workbook)
Is there more to this process?
Thanks for any tips
ScottGem
Mar 14, 2008, 12:17 PM
Depends on what the macro does. It might be dependent on cell names that no longer exist.
I would copy the whole file then delete the data rather than try to copy the macros.
SC-tbfd
Mar 14, 2008, 01:22 PM
I did actually cut and paste the whole worksheet. The error that comes up is variable undefined. When I compare, the macros seem to be the same line for line (they should be I simply dragged and dropped)
Is it possible there is something integral to the macro that is hidden or outside the area I selected with my cut and paste? I don't understand how or where excel saves the macro in relation to the worksheet that I see. Is the macro actually contained in a cell (like under the button that runs the macro) or is it a collection of things saved 'outside' of the worksheet.
ScottGem
Mar 14, 2008, 05:39 PM
I believe the code is saved outside the worksheet data but as part of the workbook. Variable undefined means there is some named variable that is missing. Like I said, probably a Range name. Copying and pasting the whole sheet may miss that.