#1   Report Post  
Posted to microsoft.public.excel.misc
ASU ASU is offline
external usenet poster
 
Posts: 63
Default create

I have the following code which copies and pastes formats and formulas to the
next row. How can I make it to end with the next empty cell selected.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim lastrow As Long
If Target.Column < 1 Then Exit Sub
If Target.Row < 2 Then Exit Sub
If Not IsEmpty(Target) Then Exit Sub 'cell must be empty
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
If Target.Row < lastrow + 1 Then Exit Sub 'Row must be empty

Rows(Target.Row - 1).Copy
ActiveSheet.Paste
Application.CutCopyMode = False
On Error Resume Next
Target.EntireRow.SpecialCells(xlConstants).ClearCo ntents
Application.EnableEvents = False 'should be part of change macro
Target.Select
Application.EnableEvents = True 'should be part of change macro

End Sub
--
ASU
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
create self-generating numbers with letters and numbers cxlough41 Excel Discussion (Misc queries) 11 January 4th 06 01:16 AM
Create database in excel? wirthless New Users to Excel 7 October 30th 05 02:57 PM
quickly create extra copies of a worksheet template in a workbook simon Excel Worksheet Functions 2 October 23rd 05 07:04 PM
need to create a formula to create a timesheet but haven't a clue AHurd Excel Discussion (Misc queries) 7 August 22nd 05 12:04 PM
Create a tabular control rkg Excel Discussion (Misc queries) 0 August 8th 05 09:25 PM


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