Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding and Deleting last row


Hi, I'm learning VB and have a problem. It is very simple: I have
spread sheet for which I am writing a macro to 1) Delete the content
of the first row...this is done and then 2) find the last row wit
content and delete the content. I am having trouble writing the cod
for 2....

I have : lastrow.select
selection.clearcontents

Can anyone help?

Regard

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Finding and Deleting last row

Sub ClearLastRow()
' assuming column A has data in all rows ...
Range("A65536").End(xlUp).EntireRow.ClearContents
End Sub

Regards

Trevor


"Bourbon" wrote in message
...

Hi, I'm learning VB and have a problem. It is very simple: I have a
spread sheet for which I am writing a macro to 1) Delete the contents
of the first row...this is done and then 2) find the last row with
content and delete the content. I am having trouble writing the code
for 2....

I have : lastrow.select
selection.clearcontents

Can anyone help?

Regards


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Finding and Deleting last row

Examples that are working for the activesheet

If you can check one column you can use this example for column A

Sub test()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Cells(LR, "A").EntireRow.Delete
End Sub

If you want to delete the last row with data on the sheet use this
example with the function

Sub testing()
Cells(LastRow(ActiveSheet), "A").EntireRow.Delete
End Sub

Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Bourbon" wrote in message ...

Hi, I'm learning VB and have a problem. It is very simple: I have a
spread sheet for which I am writing a macro to 1) Delete the contents
of the first row...this is done and then 2) find the last row with
content and delete the content. I am having trouble writing the code
for 2....

I have : lastrow.select
selection.clearcontents

Can anyone help?

Regards


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding and Deleting last row


Thanks very much, it worked...

Very appreciated

Cia

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

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
finding duplicate cell and deleting both Pat Jones Excel Worksheet Functions 6 November 2nd 07 03:05 AM
Finding and deleting macro in a workbook starguy Excel Discussion (Misc queries) 4 June 23rd 06 11:35 AM
Finding a cell match then deleting a row. Tim M Excel Discussion (Misc queries) 2 May 18th 06 05:03 PM
Finding and Deleting QPapillon New Users to Excel 2 March 14th 06 03:04 AM
Finding and deleting question marks jezzica85 Excel Discussion (Misc queries) 3 February 25th 06 09:05 AM


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