PC Review


Reply
Thread Tools Rate Thread

Copy data to next empty row in a range

 
 
ward376
Guest
Posts: n/a
 
      10th Mar 2008
http://www.rondebruin.nl/copy1.htm

lots of other useful stuff there also...

Cliff Edwards

 
Reply With Quote
 
 
 
 
ward376
Guest
Posts: n/a
 
      10th Mar 2008
Like this:

Option Explicit

Sub Copy_1_Value_PasteSpecial()
Dim SourceRange As Range, DestRange As Range
Dim DestSheet As Worksheet, Lr As Long

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'fill in the Source Sheet and range
Set SourceRange = Sheets("Sheet1").Range("b2:b5")

'Fill in the destination sheet and call the LastRow
'function to find the last row
Set DestSheet = Sheets("Sheet1")
Lr = LastRow(DestSheet)

'With the information from the LastRow function we can
'create a destination cell
Set DestRange = DestSheet.Range("A" & Lr + 1)

'Copy the source range and use PasteSpecial to paste in
'the destination cell
SourceRange.Copy
DestRange.PasteSpecial xlPasteValues, , False, False
Application.CutCopyMode = False

With Application
.ScreenUpdating = True
.EnableEvents = True
End With

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

Clioff Edwards



 
Reply With Quote
 
Aldo Cella
Guest
Posts: n/a
 
      10th Mar 2008
How would I code this? If I wanted to copy B2:B5 and Paste Special (Values)
to the next empty row in the following range, C1:K20. I'm drawing a complete
blank. I can make a macro, but I don't know how to code it to look for the
next empty row, and paste special the values.

Thanks in advance,

John

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy range if column N is empty ajm1949 Microsoft Excel Programming 24 13th May 2010 05:00 AM
Copy range from Sheet1 into empty range in Sheet2 Buddy Microsoft Excel Programming 1 19th Aug 2009 12:07 AM
Copy Values to next empty cell range Aldo Cella Microsoft Excel Worksheet Functions 1 10th Mar 2008 11:22 PM
Copy after autofilter if range is not empty =?Utf-8?B?dGlnZ2Vy?= Microsoft Excel Programming 0 14th Nov 2007 02:41 PM
find first empty cell in range and then copy from another workbook rachitm@gmail.com Microsoft Excel Discussion 1 27th Jan 2007 11:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:06 AM.