View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Alan[_2_] Alan[_2_] is offline
external usenet poster
 
Posts: 116
Default Select 1st cell of specified sheet in before close event

Open the workbook. Press Alt/F11 at the same time.
You will see your workbook on the left hand side it will look something like
this:VBAProject(Your Workbook).
Click the + sign beside your VBAProject(Your Workbook).
Keep clicking + signs until you see a "ThisWorkbook" icon.
Right click on the "ThisWorkbook" icon and select "View Code".
Paste the code that Dave gave you into the blank window on the right.
Click the save icon on the Visual Basic Editor toolbar or close the editor
and save the workbook before closing.

The next time the workbook opens, it will always move the activecell to
sheet1, A1.

Regards,

Alan


"DK" wrote in message
oups.com...
Hello Dave,
Thank you for your reply. I tried to create this but it did not work.
I am a fairly new user. Can you please give me some more steps on how
to create this?

Also, if I have 15 sheets, and on close/open, I want to place the
cursor in the first cell of each sheet and finally make Sheet 1 as
active sheet, can this be incorporated as well?

Thanks!
On Feb 28, 6:16 pm, Dave Peterson wrote:
I wouldn't use the workbook_beforeclose event. If you do, you'll have to
make
sure that you save. If you don't save, then the selection change isn't
really
done.

If you do save (and the user just wanted to close without saving), then
you may
be saving some bad changes!

I'd use the workbook_Open event.

Option explicit
sub workbook_Open()
application.goto worksheets(1).range("a1"), scroll:=true
end sub

DK wrote:

Hello!


I need help in creating a before close event. If the workbook has 16
sheets and the users saves it with the cursor in any sheet, a before
close event should be called which will ensure that the cursor is
placed in the first cell of the first sheet.


Can someone please assist me in this?


Thanks! - DK


--

Dave Peterson