Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 577
Default last cell without a blank

I have a series of dates in cells a1:z1 and some numeric data in some of the
cells a2:z32. I would like to find the last column that contains a value in
any of the data cells (all columns after that contain a blank) and then
select the date cell that corresponds to it. Can anyone help? Thanks.

a b c d e ... z
1 1/07 2/07 3/07 4/07 5/07
2 5 0 7 2
3 0 0
4 0 1 6 98 12
5 4 3 0 0 1
..
..
32

In this example it would pick 5/07
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default last cell without a blank

Try,

Range("IV2").End(xlToLeft).Offset(-1, 0).Select

Mike

"Scott" wrote:

I have a series of dates in cells a1:z1 and some numeric data in some of the
cells a2:z32. I would like to find the last column that contains a value in
any of the data cells (all columns after that contain a blank) and then
select the date cell that corresponds to it. Can anyone help? Thanks.

a b c d e ... z
1 1/07 2/07 3/07 4/07 5/07
2 5 0 7 2
3 0 0
4 0 1 6 98 12
5 4 3 0 0 1
.
.
32

In this example it would pick 5/07

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 577
Default last cell without a blank

That didnt seem to work. What is the "IV2" for?

"Mike H" wrote:

Try,

Range("IV2").End(xlToLeft).Offset(-1, 0).Select

Mike

"Scott" wrote:

I have a series of dates in cells a1:z1 and some numeric data in some of the
cells a2:z32. I would like to find the last column that contains a value in
any of the data cells (all columns after that contain a blank) and then
select the date cell that corresponds to it. Can anyone help? Thanks.

a b c d e ... z
1 1/07 2/07 3/07 4/07 5/07
2 5 0 7 2
3 0 0
4 0 1 6 98 12
5 4 3 0 0 1
.
.
32

In this example it would pick 5/07

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default last cell without a blank

Scot,

It starts looking in cell IV2 and moves left (xltoleft) until it finds a
populated cell and selects the cell above that.

Mike

"Scott" wrote:

That didnt seem to work. What is the "IV2" for?

"Mike H" wrote:

Try,

Range("IV2").End(xlToLeft).Offset(-1, 0).Select

Mike

"Scott" wrote:

I have a series of dates in cells a1:z1 and some numeric data in some of the
cells a2:z32. I would like to find the last column that contains a value in
any of the data cells (all columns after that contain a blank) and then
select the date cell that corresponds to it. Can anyone help? Thanks.

a b c d e ... z
1 1/07 2/07 3/07 4/07 5/07
2 5 0 7 2
3 0 0
4 0 1 6 98 12
5 4 3 0 0 1
.
.
32

In this example it would pick 5/07

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 577
Default last cell without a blank

I need to look in cells a2:z32 which is more than one row.

"Mike H" wrote:

Scot,

It starts looking in cell IV2 and moves left (xltoleft) until it finds a
populated cell and selects the cell above that.

Mike

"Scott" wrote:

That didnt seem to work. What is the "IV2" for?

"Mike H" wrote:

Try,

Range("IV2").End(xlToLeft).Offset(-1, 0).Select

Mike

"Scott" wrote:

I have a series of dates in cells a1:z1 and some numeric data in some of the
cells a2:z32. I would like to find the last column that contains a value in
any of the data cells (all columns after that contain a blank) and then
select the date cell that corresponds to it. Can anyone help? Thanks.

a b c d e ... z
1 1/07 2/07 3/07 4/07 5/07
2 5 0 7 2
3 0 0
4 0 1 6 98 12
5 4 3 0 0 1
.
.
32

In this example it would pick 5/07



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default last cell without a blank

not sure what you're looking for, but see if this helps: it will add the last
blank cell's address for rows 2 to 32 to the array, so your example would look
like this if column F was blank

$F$2
$E$3
$F$4
$F$5


Sub Real_lastrow()
Dim lastcol As Long
Dim ws As Worksheet
Dim arr As Variant
Dim addr As String
Dim i As Long
Set ws = Worksheets("Sheet1")
lastcol = ws.Cells(1, Columns.Count).End(xlToLeft).Column
ReDim arr(1 To lastcol)

For i = 2 To 32
addr = ws.Cells(i, Columns.Count).End(xlToLeft).Offset(, 1).Address
If IsEmpty(Range(addr)) Then
On Error Resume Next
arr(i) = addr
Debug.Print arr(i)
On Error GoTo 0
End If
Next
End Sub

--


Gary


"Scott" wrote in message
...
I have a series of dates in cells a1:z1 and some numeric data in some of the
cells a2:z32. I would like to find the last column that contains a value in
any of the data cells (all columns after that contain a blank) and then
select the date cell that corresponds to it. Can anyone help? Thanks.

a b c d e ... z
1 1/07 2/07 3/07 4/07 5/07
2 5 0 7 2
3 0 0
4 0 1 6 98 12
5 4 3 0 0 1
.
.
32

In this example it would pick 5/07



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 577
Default last cell without a blank

Thanks Gary. I was hoping something like this would do but is only seems to
work on row 2 of the group of cells

LastDate = Range("Z2:Z5").End(xlToLeft).Offset(-1, 0)

-------------------------------------------

"Gary Keramidas" wrote:

not sure what you're looking for, but see if this helps: it will add the last
blank cell's address for rows 2 to 32 to the array, so your example would look
like this if column F was blank

$F$2
$E$3
$F$4
$F$5


Sub Real_lastrow()
Dim lastcol As Long
Dim ws As Worksheet
Dim arr As Variant
Dim addr As String
Dim i As Long
Set ws = Worksheets("Sheet1")
lastcol = ws.Cells(1, Columns.Count).End(xlToLeft).Column
ReDim arr(1 To lastcol)

For i = 2 To 32
addr = ws.Cells(i, Columns.Count).End(xlToLeft).Offset(, 1).Address
If IsEmpty(Range(addr)) Then
On Error Resume Next
arr(i) = addr
Debug.Print arr(i)
On Error GoTo 0
End If
Next
End Sub

--


Gary


"Scott" wrote in message
...
I have a series of dates in cells a1:z1 and some numeric data in some of the
cells a2:z32. I would like to find the last column that contains a value in
any of the data cells (all columns after that contain a blank) and then
select the date cell that corresponds to it. Can anyone help? Thanks.

a b c d e ... z
1 1/07 2/07 3/07 4/07 5/07
2 5 0 7 2
3 0 0
4 0 1 6 98 12
5 4 3 0 0 1
.
.
32

In this example it would pick 5/07




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
Average Formula to display blank cell if named range is blank Rachael F Excel Worksheet Functions 3 February 22nd 08 05:05 PM
Start Cell B1 then find first blank cell, insert subtotal, next non blank, then next blank, sutotal cells in between......... [email protected][_2_] Excel Programming 2 June 7th 07 09:27 PM
Need macro to check if cell is not blank & previous cell is blank, copy information from row above & paste JenIT Excel Programming 4 April 12th 07 08:56 PM
Copy to first Blank cell in Colum C Non blank cells still exist be Ulrik loves horses Excel Programming 2 October 8th 06 07:35 PM
COPY A CONCATENATE CELL TO BLANK CELL PUTTING IN THE NEXT BLANK C. QUEST41067 Excel Discussion (Misc queries) 1 January 15th 05 09:29 PM


All times are GMT +1. The time now is 10:09 PM.

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"