Copy paste special transpose VBA

chef

Well-known Member
Joined
Jul 10, 2002
Messages
568
Office Version
  1. 365
  2. 2016
Hi,
I'm not that great with VBA but trying to piece together from learning on utube etc

I have a worksheet called "Pay" and and another worksheet called "Trend"

I want to copy figures and formats from "Pay" range J2:12 and then copy paste special them in the next available blank rows in "Trend" in columns D:N, but also transpose the column data in "pay" to rows in "Trend"

I've tried the following but I need to find the next blank row in "trend" and hoping this makes sense to someone.
Using O365

What I have tried but not gluing together nor fully understanding as Im not sure how to code the next available row into this

sub CopyData()
Worksheets("Pay").Range("J2:J12")
Selection.copy
Worksheets("Trend").Range(D29:N29.Select)
Selection.PasteSpecialPaste:=xlPasteValues,Transpose:=True
Application.CutCopyMode=False

End Sub

Can someone please give me a nudge in the right direction as I want to attach this to a button and just click to have updated automatically each week when the pay figures change
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
65,587
Office Version
  1. 365
Platform
  1. Windows
How about
VBA Code:
Sub chef()
   With Sheets("Trend").Range("D" & Rows.Count).End(xlUp).Offset(1)
      .Resize(, 11).Value = Application.Transpose(Sheets("Pay").Range("J2:J12").Value)
   End With
End Sub
 

chef

Well-known Member
Joined
Jul 10, 2002
Messages
568
Office Version
  1. 365
  2. 2016
wow!!!
You made that so simple and effective.

Works a dream and thank you so much for doing this and with quick response.
Really appreciate.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
65,587
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Forum statistics

Threads
1,147,476
Messages
5,741,351
Members
423,657
Latest member
Medrok2021

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
Top