• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

copy- paste via VBA

Afarag

Member
dears,

i want to copy data from sheet and paste it in another sheet, that i want to copy more than one column in one range
 
I think we need a little more information on what you're trying to do. Otherwise:


Sub copy()
Dim rInput As Range
Dim rOutput As Range
Dim aData As Variant

Set rInput = Sheets("sheet1").UsedRange
aData = rInput
Set rOutput = Sheets("sheet2").Range("a1")
rOutput.Resize(UBound(aData, 1), UBound(aData, 2)) = aData


End Sub
 
Dear

i' so sorry for confusion
if i want to copy A1 to A10 in the same sheet, can you provide me with the code
 
Will this automatic or will you have a command button to make your transfer?
On workbook open? Every 5 minutes? instant?

Should it be a copy and Paste Value or the exact replicate of A1?
 
Code:
Range("A1").Copy
Range("A10").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
 
You could always add the following to make it that if you insert anything in A1 then A10 will be added the same thing:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
Range("A1").Copy
Range("A10").PasteSpecial
Application.CutCopyMode = False
End If
End Sub

Note: Modify your code to your needs, if you only need to paste but if you need to paste the value then

Code:
Range("A10").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
 
Back
Top