Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default macro to find the last blank cell in col. A

hi guys,
how can I write a Macro to set the Activecell in the activesheet on the last
blank cell in column A?
thanks in advance.
peiman
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default macro to find the last blank cell in col. A

cells(rows.count, "A").end(xlup).Offset(1,0).Select
--
HTH...

Jim Thomlinson


"peyman" wrote:

hi guys,
how can I write a Macro to set the Activecell in the activesheet on the last
blank cell in column A?
thanks in advance.
peiman

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default macro to find the last blank cell in col. A

This may in fact be what the OP wants, but it doesn't find the *last*
blank cell...

In article ,
Jim Thomlinson wrote:

cells(rows.count, "A").end(xlup).Offset(1,0).Select

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default macro to find the last blank cell in col. A

To be absolutely correct the last blank Cell in Column A is probably A65536
(it is the last cell in A and it is probalby blank) but I figured that that
is not what the OP wanted... You are correct though it is all in how you read
the question.
--
HTH...

Jim Thomlinson


"JE McGimpsey" wrote:

This may in fact be what the OP wants, but it doesn't find the *last*
blank cell...

In article ,
Jim Thomlinson wrote:

cells(rows.count, "A").end(xlup).Offset(1,0).Select


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,316
Default macro to find the last blank cell in col. A

Assuming that column A has a contiguous block of data until the next blank
cell is reached, the following macro should do the trick:

Sub LastBlankCell()

Dim varVal As Variant
Dim l As Long

varVal = Range("A1").Value

Do Until varVal = ""
l = l + 1
varVal = Range("A1").Offset(l).Value
Loop

Range("A" & (l + 1)).Select

End Sub

--
Kevin Backmann


"peyman" wrote:

hi guys,
how can I write a Macro to set the Activecell in the activesheet on the last
blank cell in column A?
thanks in advance.
peiman



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default macro to find the last blank cell in col. A

how about finding the last non-blank cell in col A?
thanks

"Kevin B" wrote:

Assuming that column A has a contiguous block of data until the next blank
cell is reached, the following macro should do the trick:

Sub LastBlankCell()

Dim varVal As Variant
Dim l As Long

varVal = Range("A1").Value

Do Until varVal = ""
l = l + 1
varVal = Range("A1").Offset(l).Value
Loop

Range("A" & (l + 1)).Select

End Sub

--
Kevin Backmann


"peyman" wrote:

hi guys,
how can I write a Macro to set the Activecell in the activesheet on the last
blank cell in column A?
thanks in advance.
peiman

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default macro to find the last blank cell in col. A

that's great.thanx Kevin

"Kevin B" wrote:

Assuming that column A has a contiguous block of data until the next blank
cell is reached, the following macro should do the trick:

Sub LastBlankCell()

Dim varVal As Variant
Dim l As Long

varVal = Range("A1").Value

Do Until varVal = ""
l = l + 1
varVal = Range("A1").Offset(l).Value
Loop

Range("A" & (l + 1)).Select

End Sub

--
Kevin Backmann


"peyman" wrote:

hi guys,
how can I write a Macro to set the Activecell in the activesheet on the last
blank cell in column A?
thanks in advance.
peiman

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default macro to find the last blank cell in col. A

One way:

Did you mean last *blank* cell? One way:

Public Sub LastBlankInColumnA()
With ActiveSheet.Columns(1).Cells
If Application.CountA(.Cells) = .Count Then Exit Sub 'No blanks
With .Cells(.Rows.Count, 1)
If IsEmpty(.Value) Then
.Activate
ElseIf IsEmpty(.Offset(-1, 0).Value) Then
.Offset(-1, 0).Activate
Else
.End(xlUp).Offset(-1, 0).Activate
End If
End With
End With
End Sub

In article ,
peyman wrote:

hi guys,
how can I write a Macro to set the Activecell in the activesheet on the last
blank cell in column A?
thanks in advance.
peiman

  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default macro to find the last blank cell in col. A

Just start from the bottom and work upwards:

Sub sellstblcell()
Dim i As Long
For i = Rows.Count To 1 Step -1
If IsEmpty(Cells(i, "A")) Then
Cells(i, "A").Select
Exit Sub
End If
Next
End Sub

--
Gary''s Student - gsnu200745


"peyman" wrote:

hi guys,
how can I write a Macro to set the Activecell in the activesheet on the last
blank cell in column A?
thanks in advance.
peiman

  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default macro to find the last blank cell in col. A

hi,
this macro takes the active cell to A65536!!!

"Gary''s Student" wrote:

Just start from the bottom and work upwards:

Sub sellstblcell()
Dim i As Long
For i = Rows.Count To 1 Step -1
If IsEmpty(Cells(i, "A")) Then
Cells(i, "A").Select
Exit Sub
End If
Next
End Sub

--
Gary''s Student - gsnu200745


"peyman" wrote:

hi guys,
how can I write a Macro to set the Activecell in the activesheet on the last
blank cell in column A?
thanks in advance.
peiman



  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default macro to find the last blank cell in col. A

Well, you asked for the last blank cell in column A. Jim Thomlinson gave you
a quick way to get to the first blank cell after the last non-blank cell in
column A, I'll repeat that he

Sub NextBlankAfterLastNonBlank()
Range("A" & Rows.Count).End(xlup).Offset(1,0).Select
End sub

and a minor variation of that gets you to the last cell with something in
it, which was also provided earlier?

Sub LastCellWithSomethingInIt()
Range("A" & Rows.Count).End(xlup).Select
End sub


"peyman" wrote:

hi,
this macro takes the active cell to A65536!!!

"Gary''s Student" wrote:

Just start from the bottom and work upwards:

Sub sellstblcell()
Dim i As Long
For i = Rows.Count To 1 Step -1
If IsEmpty(Cells(i, "A")) Then
Cells(i, "A").Select
Exit Sub
End If
Next
End Sub

--
Gary''s Student - gsnu200745


"peyman" wrote:

hi guys,
how can I write a Macro to set the Activecell in the activesheet on the last
blank cell in column A?
thanks in advance.
peiman

  #12   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default macro to find the last blank cell in col. A

thank you.can you let me know how the "Range("A" &
Rows.Count).End(xlup).Select" works?!!what's the function of End(xlup)??!!!

"JLatham" wrote:

Well, you asked for the last blank cell in column A. Jim Thomlinson gave you
a quick way to get to the first blank cell after the last non-blank cell in
column A, I'll repeat that he

Sub NextBlankAfterLastNonBlank()
Range("A" & Rows.Count).End(xlup).Offset(1,0).Select
End sub

and a minor variation of that gets you to the last cell with something in
it, which was also provided earlier?

Sub LastCellWithSomethingInIt()
Range("A" & Rows.Count).End(xlup).Select
End sub


"peyman" wrote:

hi,
this macro takes the active cell to A65536!!!

"Gary''s Student" wrote:

Just start from the bottom and work upwards:

Sub sellstblcell()
Dim i As Long
For i = Rows.Count To 1 Step -1
If IsEmpty(Cells(i, "A")) Then
Cells(i, "A").Select
Exit Sub
End If
Next
End Sub

--
Gary''s Student - gsnu200745


"peyman" wrote:

hi guys,
how can I write a Macro to set the Activecell in the activesheet on the last
blank cell in column A?
thanks in advance.
peiman

  #13   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default macro to find the last blank cell in col. A

Excel Help is your friend. .End is the end of a range of like-contents
cells, either empty or blank. It takes one of 4 pararameters: xlUp, xlDown,
xlToLeft, xlToRight. so by using the command we did, we said
Start looking at A65536 ("A" & Rows.Count) and look UP (xlUP) to find the
end of the range - the assumption being that A65536 is most likely empty, so
it finds the first non empty cell as it looks UP the sheet from the bottom.
The .Offset(1,0) says "AHA!! You found a non-empty cell, now tell me what row
the cell right below that one is in." which is the first empty cell after the
last used cell in a given column.

"peyman" wrote:

thank you.can you let me know how the "Range("A" &
Rows.Count).End(xlup).Select" works?!!what's the function of End(xlup)??!!!

"JLatham" wrote:

Well, you asked for the last blank cell in column A. Jim Thomlinson gave you
a quick way to get to the first blank cell after the last non-blank cell in
column A, I'll repeat that he

Sub NextBlankAfterLastNonBlank()
Range("A" & Rows.Count).End(xlup).Offset(1,0).Select
End sub

and a minor variation of that gets you to the last cell with something in
it, which was also provided earlier?

Sub LastCellWithSomethingInIt()
Range("A" & Rows.Count).End(xlup).Select
End sub


"peyman" wrote:

hi,
this macro takes the active cell to A65536!!!

"Gary''s Student" wrote:

Just start from the bottom and work upwards:

Sub sellstblcell()
Dim i As Long
For i = Rows.Count To 1 Step -1
If IsEmpty(Cells(i, "A")) Then
Cells(i, "A").Select
Exit Sub
End If
Next
End Sub

--
Gary''s Student - gsnu200745


"peyman" wrote:

hi guys,
how can I write a Macro to set the Activecell in the activesheet on the last
blank cell in column A?
thanks in advance.
peiman

  #14   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default macro to find the last blank cell in col. A

It's the equivalent of selecting A65536 (in xl97-xl2003) and then hitting the
End key (on the keyboard) then the uparrow and finally the down arrow
(.offset(1,0)).



peyman wrote:

thank you.can you let me know how the "Range("A" &
Rows.Count).End(xlup).Select" works?!!what's the function of End(xlup)??!!!

"JLatham" wrote:

Well, you asked for the last blank cell in column A. Jim Thomlinson gave you
a quick way to get to the first blank cell after the last non-blank cell in
column A, I'll repeat that he

Sub NextBlankAfterLastNonBlank()
Range("A" & Rows.Count).End(xlup).Offset(1,0).Select
End sub

and a minor variation of that gets you to the last cell with something in
it, which was also provided earlier?

Sub LastCellWithSomethingInIt()
Range("A" & Rows.Count).End(xlup).Select
End sub


"peyman" wrote:

hi,
this macro takes the active cell to A65536!!!

"Gary''s Student" wrote:

Just start from the bottom and work upwards:

Sub sellstblcell()
Dim i As Long
For i = Rows.Count To 1 Step -1
If IsEmpty(Cells(i, "A")) Then
Cells(i, "A").Select
Exit Sub
End If
Next
End Sub

--
Gary''s Student - gsnu200745


"peyman" wrote:

hi guys,
how can I write a Macro to set the Activecell in the activesheet on the last
blank cell in column A?
thanks in advance.
peiman


--

Dave Peterson
  #15   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default macro to find the last blank cell in col. A

If you are using a version of Excel prior to 2007 and if cell A65536 is
empty, then A65536 is the correct cell to be Selected
--
Gary''s Student - gsnu200745


"peyman" wrote:

hi,
this macro takes the active cell to A65536!!!

"Gary''s Student" wrote:

Just start from the bottom and work upwards:

Sub sellstblcell()
Dim i As Long
For i = Rows.Count To 1 Step -1
If IsEmpty(Cells(i, "A")) Then
Cells(i, "A").Select
Exit Sub
End If
Next
End Sub

--
Gary''s Student - gsnu200745


"peyman" wrote:

hi guys,
how can I write a Macro to set the Activecell in the activesheet on the last
blank cell in column A?
thanks in advance.
peiman



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
How do I find the next blank cell in a range? EazyCure Excel Worksheet Functions 6 June 11th 07 09:14 PM
Find First Non blank cell than find column header and return that value Silver Rose Excel Worksheet Functions 10 April 30th 07 05:56 PM
Find 1st blank cell in column & sum to the same row in another col Sharon Excel Worksheet Functions 2 March 7th 07 03:00 AM
IF function which can find a blank cell owl37 Excel Worksheet Functions 5 October 19th 06 05:48 PM
find the first and last non blank cell in a row Allan from Melbourne Excel Discussion (Misc queries) 3 May 19th 06 01:12 PM


All times are GMT +1. The time now is 03:44 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"