Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro required

Hi
I would like a macro that will find the first empty line under col A:
I would also like that macro to activate as soon as the Excel file is opened.
Thanks
Ian M
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Macro required

pcorcele wrote:

I would like a macro that will find the first empty line under col A:
I would also like that macro to activate as soon as the Excel file is
opened.


Depends on what you mean by "first empty line".

If you mean "the line under the bottom used row", put this in the workbook's
ThisWorkbook object:

Private Sub Workbook_Open()
Cells(Cells.SpecialCells(xlCellTypeLastCell).Row + 1, 1).Select
End Sub


If you mean "the first line that happens to have nothing in it", use this
instead:

Private Sub Workbook_Open()
For x = 1 To Cells.SpecialCells(xlCellTypeLastCell).Row
For y = 1 To Cells.SpecialCells(xlCellTypeLastCell).Column
If Len(Cells(x, y).Formula) Then GoTo notEmpty
Next
'this is what we want
Cells(x, 1).Select
Exit Sub
notEmpty:
Next
Cells(Cells.SpecialCells(xlCellTypeLastCell).Row + 1, 1).Select
End Sub


If you mean *anything else*, you'll need to clarify.

--
I think we've found Satan's toilet.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Macro required

Try...

Cells(Rows.Count, 1).End(xlUp)(2).Select

...in Workbook_Open event or Auto_Open sub. Note that this will select
A2 if colA is empty. Otherwise, if A19 is the last non-empty cell in
colA then A20 will be selected.

If you want the first empty cell in colA below the first row...

Cells(1,1).End(xldown)(2).Select

...which assumes A1 is not empty, but there are some blank cells between
A1 and the last non-empty row in colA.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro required PCOR Excel Worksheet Functions 3 December 11th 05 07:36 PM
Pilgrim needs help: Effecting keystroks required by a macro nested within a macro. [email protected] Excel Programming 1 May 14th 05 03:46 AM
Macro help required Ian Macfarlane Excel Programming 3 May 6th 05 08:29 PM
vba macro required ? Peter O'Leary Links and Linking in Excel 1 April 14th 05 11:49 PM
Macro help required! Don Niall Excel Programming 7 June 24th 04 07:12 PM


All times are GMT +1. The time now is 01:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"