VBA: PasteSpecial Using Destination Command

brian_griffin

New Member
Joined
Oct 30, 2012
Messages
7
Hello everyone,

I using a VBA code to copy cells from various excel sheets into one master sheet.

I have managed to employ VBA to copy single cells, but now I would like to copy a range of cells and transpose them into the master sheet.

However, I am not able to adapt the paste special command with the destination command.

My recent code is:
Code:
Dim WBQ As Workbook
Dim WBZ As Workbook
Dim lngAnzahl As Long
Dim lngLastQ As Long
 Set WBZ = ActiveWorkbook

...

Set WBQ = Workbooks.Open(Filename:=varDateien(lngAnzahl))
  lngLastQ = WBQ.Worksheets(1).Range("A65536").End(xlUp).Row
  WBQ.Worksheets(1).Range("H22").Copy _
  Destination:=WBZ.Worksheets(1).Range("J" & WBZ.Worksheets(1).Range("J65536").End(xlUp).Row + 1)
WBQ.Close


I would like to copy the cells H22 to H30 into the destination worksheet.

Has anyone any hint? I really appreciate any help.

Thanks in advance,
Brian
 
You can prevent that by calling Application.CutCopyMode = False

That will only clear the little 'Marching Ants' the appear around the range that was copied.
It will not change the fact that the range you pasted to got selected.
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
What about copying a worksheet from one workbook to another? I'm trying to copy/paste values on one workbook, and paste it to another workbook that is closed (it could be open, it doesn't matter to me). The problem line I'm getting is:

Code:
 Sheets(wksht).Copy Destination:=newwkbk.Sheets("Sheet1")

I'm not sure why it's not working. Any ideas?

By luck, I obtained the result through the following code:
Code:
 Selection.Copy Destination:=Workbooks([I]yourWorkbook[/I].Name).Sheets("[I]nameSheet[/I]").Range("A1")

Ciao
Fabiana
 
Upvote 0
Hello. I´m Trying to copy some rows from a sheet and paste them under the active cell but transposed. I´m using this single code

Sub Mis_Datos()
Range("J9:M12").Copy
Range(Cells(ActiveCell.Row + 1, ActiveCell.Column)).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True




End Sub


But I get the following error:

Error en el método 'Range' de objeto '_Global'

Any help please??
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

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