Saving Vba Code

  • Thread starter Rick, United Kingdom
  • Start date
R

Rick, United Kingdom

Ok I know this sounds pretty silly, but. How do you save VBA code. spent all
of yesturday putting down loads of code, saved the work book and closed down,
came back to it this morning and nothing! lost the lot. As you can imagine,
not a happy teddy bear!
 
E

Earl Kiosterud

Rick,

Your code, whether you write it yourself in the VBE, or record it with the
macro recorder, goes into modules kept in a workbook. In the VBE, the
Project Explorer (a pane usually open at left), which is in outline format,
lets you open various modules.

Open any workbooks you'd have had open. Then go to the VBE (Alt-F11). If
there's no Project Explorer, do View - Project Explorer. Each open workbook
is a project, and if there's a Personal.xls workbook (which can also contain
macros), you can open the modules of that too. The projects may be
collapsed (there'll be a +, click it to expand). Double-click each module,
hoping you'll find the one that has your code.
 
C

Chip Pearson

VBA code is always stored in the workbook, so if you save the
workbook it should save the code. It could be the case that your
workbook is corrupted, making the VBA unreadable. Unfortunately,
there is nothing you can do about it.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Rick, United Kingdom"
 
K

Ken Wright

If however you recall a message coming up when you closed Excel saying 'You
have made changes to your Personal macro Workbook - Do you wish to save
those changes" and you hit no, then that is likely where the code went and
is now lost.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

------------------------------­------------------------------­----------------
It's easier to beg forgiveness than ask permission :)
------------------------------­------------------------------­----------------
 
E

Earl Kiosterud

Ken,

Yeah. That's absolutely right. I meant to mention that any workbooks
containing macro code would have to be saved. Take heart, Rick. It never
takes as long the second time.
 
R

Rick, United Kingdom

Thanks Earl I just finished rewriting the code (in the evenings) anywya i
think i figured out what went wrong. the original workbook was built on excel
2000. And the code was wriitten after i upgraded to 2003. so i am guessing
that the upgrade either corrupted the file or some pesky gremlins got in the
works! any way rebuilt the enitire work book and it save vba code fine!
Yippee! thanks again
 
Top