Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default Copy data to next empty row in a range

http://www.rondebruin.nl/copy1.htm

lots of other useful stuff there also...

Cliff Edwards

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default Copy data to next empty row in a range

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Copy data to next empty row in a range

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
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
Copy Values to next empty cell range Aldo Cella Excel Worksheet Functions 1 March 10th 08 11:22 PM
Copy after autofilter if range is not empty tigger Excel Programming 0 November 14th 07 02:41 PM
find first empty cell in range and copy information from another workbook [email protected] Excel Programming 19 January 31st 07 02:01 AM
Copy last row with data to next empty row... Oreg[_53_] Excel Programming 7 November 3rd 05 01:51 PM
Copy last row with data to next empty row... Oreg[_52_] Excel Programming 0 November 2nd 05 01:05 AM


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