VBA Code help..copy & paste at end of range

ExcelKid_10

Board Regular
Joined
Mar 17, 2004
Messages
87
Hello-

As a follow up to an earlier post I have the following code which I from this board that I need a little help modifying:

Sub CopyData()
'
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("MASTER").Select
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub

What I would like to do is add a line after the code takes you to the last row in column and go one more down (which will be a blank cell/row) and paste my data there. Can anyone help with this?

Thanks!!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi,

I don´t know the author of your posted code, but.... :rolleyes:

Select The Selection!!! :wink:

Do you want to copy the Range in the same sheet?

Try this:

Code:
Option Explicit

Sub Copy()
   With ActiveSheet
    .Range("A1").CurrentRegion.Copy
    .Paste Destination:=.Range("A" & Range("A65536").End(xlUp).Row + 2)
   End With
Application.CutCopyMode = False
End Sub

Is that what you want?
 
Upvote 0
very close...instead of pasting it on the current worksheet i would like it to paste on another worksheet called "Master". Can you help me do that? Your help is much appreciated!
 
Upvote 0
Hi,

try now:

Code:
Option Explicit

Sub Copy()
Dim lngI As Long
 ActiveSheet.Range("A1").CurrentRegion.Copy
 lngI = Sheets("MASTER").Range("A65536").End(xlUp).Row + 2
  If lngI = 3 Then
   lngI = 2
  End If

        With Sheets("MASTER")
            .Activate
            .Paste Destination:=.Cells(lngI, 1)
        End With
    
    Application.CutCopyMode = False
End Sub
 
Upvote 0
Thank you so much! Works perfect. One more ?....can you help me paste-special values instead of just pasting?

Thanks!!! your help is much appreciated.
 
Upvote 0
Hi,

one more? No prob.

Code:
Option Explicit
Sub Copy()
Dim lngI As Long
 ActiveSheet.Range("A1").CurrentRegion.Copy
 lngI = Sheets("MASTER").Range("A65536").End(xlUp).Row + 2
  If lngI = 3 Then
   lngI = 2
  End If
Application.ScreenUpdating = False
        With Sheets("MASTER")
            .Activate
            .Cells(lngI, 1).PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=False
            .Cells(lngI, 1).Select
        End With
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
  MsgBox ("Finished")
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,807
Messages
6,121,679
Members
449,047
Latest member
notmrdurden

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top