Macro to copy data from one layout to another layout

JannetteChristie

Board Regular
Joined
Dec 14, 2015
Messages
119
Can anyone help with this please, I am trying to write some VBA to copy the following data in my spreadsheet to move to this format.

Starting layout:


Excel 2012
CDEFGHIJKLMNO
2VR3-0510-LHMDUTYPOINT3FS5-WRAS1COMM11FRB502
3DE0
4qp-35PRESSURISATION0
5ec50CONDITIONER2DPS-WMB-EC502DPS-FMB-EC501
6cx65cSEP0
7in15-50-p-h2HIU0
8DPS-SP1DPS-NOTE1
9
10
11
12
13
14
Save & Print prepare


New layout required:

Excel 2012
TU
2VR3-0510-LHM
3FS5-WRAS1
4COMM11
5FRB502
6DE
7QP-35
8EC50
9DPS-WMB-EC502
10DPS-FMB-EC501
11cx65c
12IN15-50-P-H2
13DPS-SP
14DPS-NOTE1
Save & Print prepare


I am sure this is possible but not sure how to code this.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
If the upper bound of Nary is 100 I don't understand how you could have rr as 110. It should have failed at 101.
What line is highlighted when you get the error?
 
Upvote 0
Line highlighted is: nary(rr, 1) = ary(r, 1)

When I hold my mouse over it, it says: nary(rr, 1) = ary(r, 1) = <Subscript out of range >
 
Upvote 0
My apologies, I have just realised that there was an error in my code, I did not notice the change you made to the line:

ary = Range("C2", Range("C" & Rows.Count).End(xlUp).Offset(, 10)).Value2
ReDim nary(1 To UBound(ary) + Application.Sum(Range("G:G")) + Application.Count(Range("G:G")), 1 To 2)

I have added this and it all running ok now - sorry for wasting your item, I need to be more vigilant
 
Upvote 0
No problems
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,375
Messages
6,124,578
Members
449,174
Latest member
chandan4057

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