Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default help locating first empty cell in a column


I am looking for a function that will search column A and return th
address of the first blank cell. I have been trying to do this with a
Address & Match combo as follows:


=ADDRESS(MATCH(9.99999999999999E+307,A:A)+1,1)

Alone this formula works great. However, when I put it in a macro, i
doesn't work. Here is my macro:

ActiveWorkbook.Names.Add Name:="ABC", RefersToR1C1:= _
"=OFFSET(INDIRECT(ADDRESS(MATCH(""EML*"",Sheet1!C6 ,0),6)),0,-5,COUNTIF(Sheet1!C6,LEFT(""EML*"",5)),COUNTA(Sheet 1!R4))"
ActiveWorkbook.Names.Add Name:="EMPTY", RefersToR1C1:= _
"=ADDRESS(MATCH(9.99999999999999E+307,Sheet1!R1C1) + 1,1,4)"
Range("ABC").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A4").Select
ActiveSheet.paste
Range("EMPTY").Select

Basically the macro is taking "ABC" which is a specific chunk o
accounting data in a much larger pool of data from Sheet1 an
copy/pasting it to Sheet2. What I was hoping the macro would do i
then select the first empty cell in Column A under what I just pasted.

Visual Basic doesn't seem to like my "Empty" reference. The Debugge
pops up at Range("EMPTY").Select.

Anyone have any advice. Any help is much appreciated!!

--
Cel
-----------------------------------------------------------------------
Celt's Profile: http://www.excelforum.com/member.php...fo&userid=1941
View this thread: http://www.excelforum.com/showthread.php?threadid=46835

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default help locating first empty cell in a column

If you know that A1 and A2 contain data, you can use the following:

Cells(Range("A1").End(xlDown).Row + 1, "A").Select

To cover the cases where A1 or A2 might be empty you need to add more logic.
You can test individual cells using the IsEmpty function:

If IsEmpty(Range("A1")) Then
Range("A1").Select
ElseIf IsEmpty(Range("A2")) Then
Range("A2").Select
Else
Cells(Range("A1").End(xlDown).Row + 1, "A").Select
End If

John Green - Excel MVP


"Celt" wrote in message
...

I am looking for a function that will search column A and return the
address of the first blank cell. I have been trying to do this with an
Address & Match combo as follows:


=ADDRESS(MATCH(9.99999999999999E+307,A:A)+1,1)

Alone this formula works great. However, when I put it in a macro, it
doesn't work. Here is my macro:

ActiveWorkbook.Names.Add Name:="ABC", RefersToR1C1:= _
"=OFFSET(INDIRECT(ADDRESS(MATCH(""EML*"",Sheet1!C6 ,0),6)),0,-5,COUNTIF(Sheet1!C6,LEFT(""EML*"",5)),COUNTA(Sheet 1!R4))"
ActiveWorkbook.Names.Add Name:="EMPTY", RefersToR1C1:= _
"=ADDRESS(MATCH(9.99999999999999E+307,Sheet1!R1C1) + 1,1,4)"
Range("ABC").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A4").Select
ActiveSheet.paste
Range("EMPTY").Select

Basically the macro is taking "ABC" which is a specific chunk of
accounting data in a much larger pool of data from Sheet1 and
copy/pasting it to Sheet2. What I was hoping the macro would do is
then select the first empty cell in Column A under what I just pasted.

Visual Basic doesn't seem to like my "Empty" reference. The Debugger
pops up at Range("EMPTY").Select.

Anyone have any advice. Any help is much appreciated!!!


--
Celt
------------------------------------------------------------------------
Celt's Profile:
http://www.excelforum.com/member.php...o&userid=19413
View this thread: http://www.excelforum.com/showthread...hreadid=468355



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default help locating first empty cell in a column

Hi John

Good to see you in the newsgroup

Maybe this

Sub test()
On Error GoTo BodemUp
Columns("A").Cells.SpecialCells(xlCellTypeBlanks). Cells(1).Select
Exit Sub
BodemUp: Cells(Rows.Count, "A").End(xlUp)(2).Select
End Sub

--
Regards Ron de Bruin
http://www.rondebruin.nl


"John Green" <greenj@nospam wrote in message ...
If you know that A1 and A2 contain data, you can use the following:

Cells(Range("A1").End(xlDown).Row + 1, "A").Select

To cover the cases where A1 or A2 might be empty you need to add more logic. You can test individual cells using the IsEmpty
function:

If IsEmpty(Range("A1")) Then
Range("A1").Select
ElseIf IsEmpty(Range("A2")) Then
Range("A2").Select
Else
Cells(Range("A1").End(xlDown).Row + 1, "A").Select
End If

John Green - Excel MVP


"Celt" wrote in message
...

I am looking for a function that will search column A and return the
address of the first blank cell. I have been trying to do this with an
Address & Match combo as follows:


=ADDRESS(MATCH(9.99999999999999E+307,A:A)+1,1)

Alone this formula works great. However, when I put it in a macro, it
doesn't work. Here is my macro:

ActiveWorkbook.Names.Add Name:="ABC", RefersToR1C1:= _
"=OFFSET(INDIRECT(ADDRESS(MATCH(""EML*"",Sheet1!C6 ,0),6)),0,-5,COUNTIF(Sheet1!C6,LEFT(""EML*"",5)),COUNTA(Sheet 1!R4))"
ActiveWorkbook.Names.Add Name:="EMPTY", RefersToR1C1:= _
"=ADDRESS(MATCH(9.99999999999999E+307,Sheet1!R1C1) + 1,1,4)"
Range("ABC").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A4").Select
ActiveSheet.paste
Range("EMPTY").Select

Basically the macro is taking "ABC" which is a specific chunk of
accounting data in a much larger pool of data from Sheet1 and
copy/pasting it to Sheet2. What I was hoping the macro would do is
then select the first empty cell in Column A under what I just pasted.

Visual Basic doesn't seem to like my "Empty" reference. The Debugger
pops up at Range("EMPTY").Select.

Anyone have any advice. Any help is much appreciated!!!


--
Celt
------------------------------------------------------------------------
Celt's Profile: http://www.excelforum.com/member.php...o&userid=19413
View this thread: http://www.excelforum.com/showthread...hreadid=468355





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default help locating first empty cell in a column

Thanks Ron - I see I'm getting out of touch with the current thinking<g.


"Ron de Bruin" wrote in message
...
Hi John

Good to see you in the newsgroup

Maybe this

Sub test()
On Error GoTo BodemUp
Columns("A").Cells.SpecialCells(xlCellTypeBlanks). Cells(1).Select
Exit Sub
BodemUp: Cells(Rows.Count, "A").End(xlUp)(2).Select
End Sub

--
Regards Ron de Bruin
http://www.rondebruin.nl


"John Green" <greenj@nospam wrote in message
...
If you know that A1 and A2 contain data, you can use the following:

Cells(Range("A1").End(xlDown).Row + 1, "A").Select

To cover the cases where A1 or A2 might be empty you need to add more
logic. You can test individual cells using the IsEmpty function:

If IsEmpty(Range("A1")) Then
Range("A1").Select
ElseIf IsEmpty(Range("A2")) Then
Range("A2").Select
Else
Cells(Range("A1").End(xlDown).Row + 1, "A").Select
End If

John Green - Excel MVP


"Celt" wrote in
message ...

I am looking for a function that will search column A and return the
address of the first blank cell. I have been trying to do this with an
Address & Match combo as follows:


=ADDRESS(MATCH(9.99999999999999E+307,A:A)+1,1)

Alone this formula works great. However, when I put it in a macro, it
doesn't work. Here is my macro:

ActiveWorkbook.Names.Add Name:="ABC", RefersToR1C1:= _
"=OFFSET(INDIRECT(ADDRESS(MATCH(""EML*"",Sheet1!C6 ,0),6)),0,-5,COUNTIF(Sheet1!C6,LEFT(""EML*"",5)),COUNTA(Sheet 1!R4))"
ActiveWorkbook.Names.Add Name:="EMPTY", RefersToR1C1:= _
"=ADDRESS(MATCH(9.99999999999999E+307,Sheet1!R1C1) + 1,1,4)"
Range("ABC").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A4").Select
ActiveSheet.paste
Range("EMPTY").Select

Basically the macro is taking "ABC" which is a specific chunk of
accounting data in a much larger pool of data from Sheet1 and
copy/pasting it to Sheet2. What I was hoping the macro would do is
then select the first empty cell in Column A under what I just pasted.

Visual Basic doesn't seem to like my "Empty" reference. The Debugger
pops up at Range("EMPTY").Select.

Anyone have any advice. Any help is much appreciated!!!


--
Celt
------------------------------------------------------------------------
Celt's Profile:
http://www.excelforum.com/member.php...o&userid=19413
View this thread:
http://www.excelforum.com/showthread...hreadid=468355







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default help locating first empty cell in a column

Sub test()
Dim rngFirstEmpty As Range
Dim wks As Worksheet

Set wks = ActiveSheet 'or whatever sheet you want
Set rngFirstEmpty = wks.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
MsgBox "The first empty cell is in address " & rngFirstEmpty.Address
'rngFirstEmpty.Select 'Uncomment this to select this cell
End Sub
--
HTH...

Jim Thomlinson


"Celt" wrote:


I am looking for a function that will search column A and return the
address of the first blank cell. I have been trying to do this with an
Address & Match combo as follows:


=ADDRESS(MATCH(9.99999999999999E+307,A:A)+1,1)

Alone this formula works great. However, when I put it in a macro, it
doesn't work. Here is my macro:

ActiveWorkbook.Names.Add Name:="ABC", RefersToR1C1:= _
"=OFFSET(INDIRECT(ADDRESS(MATCH(""EML*"",Sheet1!C6 ,0),6)),0,-5,COUNTIF(Sheet1!C6,LEFT(""EML*"",5)),COUNTA(Sheet 1!R4))"
ActiveWorkbook.Names.Add Name:="EMPTY", RefersToR1C1:= _
"=ADDRESS(MATCH(9.99999999999999E+307,Sheet1!R1C1) + 1,1,4)"
Range("ABC").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A4").Select
ActiveSheet.paste
Range("EMPTY").Select

Basically the macro is taking "ABC" which is a specific chunk of
accounting data in a much larger pool of data from Sheet1 and
copy/pasting it to Sheet2. What I was hoping the macro would do is
then select the first empty cell in Column A under what I just pasted.

Visual Basic doesn't seem to like my "Empty" reference. The Debugger
pops up at Range("EMPTY").Select.

Anyone have any advice. Any help is much appreciated!!!


--
Celt
------------------------------------------------------------------------
Celt's Profile: http://www.excelforum.com/member.php...o&userid=19413
View this thread: http://www.excelforum.com/showthread...hreadid=468355




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default help locating first empty cell in a column


Thanks guys!!

These are working great!! Very Very much appreciated!


--
Celt
------------------------------------------------------------------------
Celt's Profile: http://www.excelforum.com/member.php...o&userid=19413
View this thread: http://www.excelforum.com/showthread...hreadid=468355

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
Go to last non-empty cell in column Fred Holmes Excel Discussion (Misc queries) 8 January 22nd 09 10:56 PM
help locating first empty cell in a Column Celt Excel Worksheet Functions 8 September 19th 05 04:58 PM
Locating Cell Number of first occurance of data in Column genzu Excel Programming 6 June 16th 04 03:44 AM
VBA to copy to empty cell directly below a cell when analogous cells in different column have same value as each other? Steven Rosenberg Excel Programming 0 August 5th 03 06:10 AM
VBA to copy to empty cell directly below a cell when analogous cells in different column have same value as each other? SROSENYC Excel Programming 1 August 5th 03 04:34 AM


All times are GMT +1. The time now is 08:50 AM.

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

About Us

"It's about Microsoft Excel"