Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Last cell in column (with hidden rows)

I have a problem. and don't know how to solve it.....

First the situation....
I have a table on a worksheet. Every row in that table contains data but
some rows are hidden. Even the last row of that table could be hidden.
Now I want to add a new row (at the end) of the table, but when I do this by
using the code (see below), I goes wrong when the last row in the table is
hidden.
The problem is that the hidden row will be overwritten.....

ActiveCell.Copy Destination:=Range("Base_KT").End(xlDown).Offset(1 , 0)

Thanks in advance,

Paul Bleijlevens

PS: Range("Base_KZT) is the named cell in the upper left corner of the
table.....


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Last cell in column (with hidden rows)

See if this works better:

Set "A" = to column of Base_KT

Dim LASTROW As Long

LASTROW = Cells(Rows.COUNT, "A").End(xlUp).Offset(1, 0).Row

ActiveCell.Copy Destination:=Cells(LASTROW,Range("Base_KT").Column )
--
steveB

Remove "AYN" from email to respond
"Pink Panther" wrote in message
...
I have a problem. and don't know how to solve it.....

First the situation....
I have a table on a worksheet. Every row in that table contains data but
some rows are hidden. Even the last row of that table could be hidden.
Now I want to add a new row (at the end) of the table, but when I do this
by using the code (see below), I goes wrong when the last row in the table
is hidden.
The problem is that the hidden row will be overwritten.....

ActiveCell.Copy Destination:=Range("Base_KT").End(xlDown).Offset(1 , 0)

Thanks in advance,

Paul Bleijlevens

PS: Range("Base_KZT) is the named cell in the upper left corner of the
table.....




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Last cell in column (with hidden rows)

Hi Pink Panther,

Try the following which should work for visible or hidden rows:

'=============================
Sub TestIt()
Dim Lrow As Long, FirstCol As Long

Lrow = LastRow(, Range("Base_KZT").CurrentRegion)

FirstCol = Range("Base_KZT").Column

ActiveCell.Copy Destination:= _
Cells(Lrow + 1, FirstCol)

End Sub
'<<=============================

'=============================
Function LastRow(Optional sh As Worksheet, Optional rng As Range)
If sh Is Nothing Then Set sh = ActiveSheet
If rng Is Nothing Then Set rng = sh.Cells

On Error Resume Next
LastRow = rng.Find(What:="*", _
After:=rng(1), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function
'<<=============================

---
Regards,
Norman



"Pink Panther" wrote in message
...
I have a problem. and don't know how to solve it.....

First the situation....
I have a table on a worksheet. Every row in that table contains data but
some rows are hidden. Even the last row of that table could be hidden.
Now I want to add a new row (at the end) of the table, but when I do this
by using the code (see below), I goes wrong when the last row in the table
is hidden.
The problem is that the hidden row will be overwritten.....

ActiveCell.Copy Destination:=Range("Base_KT").End(xlDown).Offset(1 , 0)

Thanks in advance,

Paul Bleijlevens

PS: Range("Base_KZT) is the named cell in the upper left corner of the
table.....




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
copying one column with hidden/filtered rows to another colum Rechie Excel Discussion (Misc queries) 2 September 14th 09 06:28 PM
How do I add up column of numbers without including hidden rows? laserhallam Excel Discussion (Misc queries) 3 February 1st 08 05:35 AM
Sum of a column excluding hidden rows mnwild1 Excel Worksheet Functions 10 June 22nd 07 11:24 PM
Counting non-blank cells in a column, excluding hidden rows SisterDell Excel Worksheet Functions 3 June 1st 07 03:31 PM
Column Auto Width and Hidden Rows KWCounter Excel Discussion (Misc queries) 1 May 20th 05 12:59 AM


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