Please help with Paste Special VBA

hunter9002

New Member
Joined
Jun 1, 2012
Messages
8
I am trying to write a code where I select the active cell's row on sheet1, copy the whole row, and then paste the information vertically starting at cell B5 on sheet3.

So far I have been able to select and copy the relevant row, but I am getting errors when I paste.

Here is what I have thus far:

Private Sub CommandButton1_Click()

Dim rngData As Range

Set rngData = Rows(ActiveCell.Row)
rngData.Copy ("Sheet3")

Range("B5").Select
rngData.PasteSpecial xlPasteValues: Transpose = True

Application.CutCopyMode = False
Me.UsedRange.Rows.AutoFit
End Sub
 
Last edited:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
try replacing
rngData.PasteSpecial xlPasteValues: Transpose = True

with
rngData.PasteSpecial Paste:=xlPasteValues, Transpose:=True
 
Upvote 0
That probably works, but didn't fix it. The problem must be elsewhere.I'm getting an application-defined or objected-defined error.
 
Upvote 0
Try using this:

Private Sub CommandButton1_Click()

Dim rngData As Range

Set rngData = ActiveCell.Row
rngData.Copy

Sheets("Sheet3").Range("B5").PasteSpecial _
xlPasteValues: Transpose = True

Application.CutCopyMode = False

End Sub
 
Upvote 0
Thanks for sticking by.

Now I am getting an subscript out of range error. Perhaps copying the whole row is too much - I only need to copy data up to column AO.
 
Upvote 0
I have no problems with the following code as long as there is a sheet named "Sheet3". Otherwise, change that to suit.
Code:
Private Sub CommandButton1_Click()
Dim rngData As Range
Set rngData = Rows(ActiveCell.Row)
rngData.Copy
Sheets("Sheet3").Range("B5").PasteSpecial _
    Paste:=xlPasteValues, Transpose:=True
Application.CutCopyMode = False
End Sub
 
Upvote 0
Ah, looks like I had some syntax issues. Colons, commas, equal signs. Blah.Thanks again! Have an excellent summer.
 
Upvote 0

Forum statistics

Threads
1,203,483
Messages
6,055,663
Members
444,806
Latest member
tofanexcel

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