ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Finding the next empty cell. (https://www.excelbanter.com/excel-programming/298743-finding-next-empty-cell.html)

Unknown_User[_3_]

Finding the next empty cell.
 
Hi all,

A successful night so far as my first question was answered withi
seconds!

I want to populate the next available empty cell in a column with th
results of a VB script that returns a string.

Can anyone tell me how to locate the next empty cell?

Thanks

--
Message posted from http://www.ExcelForum.com


pikus

Finding the next empty cell.
 
lrow = ActiveSheet.UsedRange.Row + _
ActiveSheet.UsedRange.Rows.Count

Will give the first empty row. Replace the word "Row" with "Column
and get the first empty column. Is that good? - Piku

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Finding the next empty cell.
 
It will give the next row after the last row Excel considers to be used.
Considering a row to be used doesn't necessarily have anything to do with a
particular cell being empty or not although in many situations it will give
the desired result - quite unreliable for sheets with columns of varying
lengths and so forth.

--
Regards,
Tom Ogilvy



"pikus " wrote in message
...
lrow = ActiveSheet.UsedRange.Row + _
ActiveSheet.UsedRange.Rows.Count

Will give the first empty row. Replace the word "Row" with "Column"
and get the first empty column. Is that good? - Pikus


---
Message posted from http://www.ExcelForum.com/




pikus

Finding the next empty cell.
 
Any suggestions? - Piku

--
Message posted from http://www.ExcelForum.com


Unknown_User[_4_]

Finding the next empty cell.
 
Thanks.

Sorry to be so dumb. Will this return a column/row value?

Ideally I want to identify the next cell in, lets say, column A, an
use that value to identify the cell to populate;

Worksheets("Sheet1").Range([next avalable cell]).Value = string

Hopefully I am making sense....

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Finding the next empty cell.
 
Assume column A
Cells(1,1).End(xldown)(2).Value = "String"

If A1 and or A2 could be blank

Dim rng as Range
if isempty(Range("A1")) then
set rng = Range("A1")
elseif isempty(Range("A2")) then
set rng = Range("A2")
else
set rng = Range("A1").End(xldown)
End if
set rng = rng(2)

if there will never be data below the "next empty cell"

set rng =cells(rows.count,1).End(xlup)
if not isempty(rng) then _
set rng = rng(2)



--
Regards,
Tom Ogilvy

"Unknown_User " wrote in
message ...
Hi all,

A successful night so far as my first question was answered within
seconds!

I want to populate the next available empty cell in a column with the
results of a VB script that returns a string.

Can anyone tell me how to locate the next empty cell?

Thanks!


---
Message posted from http://www.ExcelForum.com/




Ron de Bruin

Finding the next empty cell.
 
If A1 and or A2 could be blank

Hi Tom is this a good option ?

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


"Tom Ogilvy" wrote in message ...
Assume column A
Cells(1,1).End(xldown)(2).Value = "String"

If A1 and or A2 could be blank

Dim rng as Range
if isempty(Range("A1")) then
set rng = Range("A1")
elseif isempty(Range("A2")) then
set rng = Range("A2")
else
set rng = Range("A1").End(xldown)
End if
set rng = rng(2)

if there will never be data below the "next empty cell"

set rng =cells(rows.count,1).End(xlup)
if not isempty(rng) then _
set rng = rng(2)



--
Regards,
Tom Ogilvy

"Unknown_User " wrote in
message ...
Hi all,

A successful night so far as my first question was answered within
seconds!

I want to populate the next available empty cell in a column with the
results of a VB script that returns a string.

Can anyone tell me how to locate the next empty cell?

Thanks!


---
Message posted from http://www.ExcelForum.com/






TJ Walls

Finding the next empty cell.
 

Try:

ActiveSheet.UsedRange.Rows.Count + 1

On Tue, 18 May 2004 16:05:00 -0500, wrote:

Hi all,

A successful night so far as my first question was answered within
seconds!

I want to populate the next available empty cell in a column with the
results of a VB script that returns a string.

Can anyone tell me how to locate the next empty cell?

Thanks!


---
Message posted from http://www.ExcelForum.com/



Tom Ogilvy

Finding the next empty cell.
 
Looks good to me Ron.

--
Regards,
Tom Ogilvy

"Ron de Bruin" wrote in message
...
If A1 and or A2 could be blank


Hi Tom is this a good option ?

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


"Tom Ogilvy" wrote in message

...
Assume column A
Cells(1,1).End(xldown)(2).Value = "String"

If A1 and or A2 could be blank

Dim rng as Range
if isempty(Range("A1")) then
set rng = Range("A1")
elseif isempty(Range("A2")) then
set rng = Range("A2")
else
set rng = Range("A1").End(xldown)
End if
set rng = rng(2)

if there will never be data below the "next empty cell"

set rng =cells(rows.count,1).End(xlup)
if not isempty(rng) then _
set rng = rng(2)



--
Regards,
Tom Ogilvy

"Unknown_User " wrote in
message ...
Hi all,

A successful night so far as my first question was answered within
seconds!

I want to populate the next available empty cell in a column with the
results of a VB script that returns a string.

Can anyone tell me how to locate the next empty cell?

Thanks!


---
Message posted from http://www.ExcelForum.com/








Tom Ogilvy

Finding the next empty cell.
 
I posted several, not sure why they seem to be ignored.

--
Regards,
Tom Ogilvy

"pikus " wrote in message
...
Any suggestions? - Pikus


---
Message posted from http://www.ExcelForum.com/




TJ Walls

Finding the next empty cell.
 

Sorry ... this one was an accident. See Tom's post above.

On Tue, 18 May 2004 17:58:57 -0400, TJ Walls wrote:


Try:

ActiveSheet.UsedRange.Rows.Count + 1

On Tue, 18 May 2004 16:05:00 -0500, wrote:

Hi all,

A successful night so far as my first question was answered within
seconds!

I want to populate the next available empty cell in a column with the
results of a VB script that returns a string.

Can anyone tell me how to locate the next empty cell?

Thanks!


---
Message posted from http://www.ExcelForum.com/




All times are GMT +1. The time now is 04:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com