Copy data from vertical cells paste into horizontal cells that will change each time macro run

KimC33

New Member
Joined
Aug 31, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I also would like to run a VBA code that will copy the data of cells highlighted in blue and paste them into the respective months in the table below. Each month the code will be different since the month will change. I haven't been able to figure out how to write the code to make it change and move down a row each new month. I wrote the copy/paste part though. Thanks for the help!

VBA Code:
Sub UpdateSysAvail2()
    Range("B28:B29").Select
    Range("B45").Select
    Selection.PasteSpecial Paste
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=True
End Sub

Data Point 1
P1 only
99.72%
P1 + P2
99.36%

Data Point History
MonthP1 OnlyP1 & P2
January99.79%99.78%
February99.99%99.82%
March100.00%97.90%
April99.19%99.08%
May99.88%99.48%
June100.00%99.87%
July99.72%99.36%
August
September
October
November
December
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Think this is what you require....

VBA Code:
Sub UpdateSysAvail2()

    Range("B28:B29").Copy
    Range("B52").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True
    
End Sub

Will see in my example below that I have copied data in cells B28 & B29 and then pasted it to the bottom of the list. I've run it twice so each time it moves it to the next row down, August and then September for me.

The code goes to row 52, then goes up to the row last used (42 initially) and then offsets (moves down) a single row to then paste the data.

1723721042655.png
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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