Position to first empty cell upon program open

S

Savannah

I have a workbook for data entry which contains many rows of data. I want my
cursor/selection to automatically position to the first applicable empty row
in Column A when I open this workbook. It currently positions to A81. Is
this the default, or can I change it? Is there a way to do this?
 
G

Gary''s Student

Include the following macro in the worksheet event code area:

Private Sub Worksheet_Activate()
n = Cells(Rows.Count, "A").End(xlUp).Row
Cells(n, "A").Select
End Sub


Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm
 
S

Savannah

I tried that, but I am not able to edit the macro... I get an error message
that says, "Project locked--project unavailable".
 
G

Gord Dibben

This will occur if your workbook is shared under Tools>Share Workbook.

Unshare to add the code.

Re-share after if necessary. The code will run.


Gord Dibben MS Excel MVP
 
S

Savannah

Thank you for your help. I unshared the workbook and added the code, but now
I get an security warning every time I open the workbook saying that the
macro has been disabled because it may contain a virus. I chose "Enable
content", but the message keeps coming up.
 
G

Gord Dibben

If your macro security is set to medium you will get the message about
disabling or enabling macros.

When you open the workbook click on "Enable Macros" to have the code run.

If you don't want to see the message you can set security to "low".......not
recommended...............or create a digital signature using MS Office
Tools SelfCert application.


Gord
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top