Copy selected cells to next page and paste in a different order!

rob999

New Member
Joined
May 19, 2011
Messages
3
Hi there,

I am having real trouble with something and I am now losing the will to live. Hopefully, a kind person out there will be able to help.

In a nutshell:

I need to copy certain cells from a row in the sheet called "Prices" into the next row (that doesn't contain data) in the sheet called "Order Summary". The column order on the two sheets is different. Is this even possible?

One further problem is that the unit prices on "Prices" are derived from a sheet called "Terminal" (as a simple =Terminal!G19 for example) and the haulage rate is the same (=Haulage!D4)

So as an example...

Prices A5 needs to go to Order Summary B4 (as it's the next data-less row)
B5 to D4
D5 to E4
E5 to C4
F5 to G4 (unit cost derived from =Terminal!G19, if that matters)
G5 to H4
H5 to I4 (haulage cost derived from =Haulage!D4)

And that's it!!

I'm a relative novice with macros, and although I have been trying to patch together something that works from various posts on here, I am really struggling. Any help would be greatly appreciated, and will save me from long nights of failure!

Thanks in advance,

Rob
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Forgot to mention something that makes this even harder - the company I work for uses Excel 2003 !! I didn't know if this made any difference to the way in which people can help?
 
Upvote 0
Hi Rob,

Welcome to MrExcel,

I don't write or understand VBA code so I am unable to help you further with this, sorry.

I have copied the following from a code I have and changed the cell references to suit yours...

Code:
Sub CopyData()
Application.ScreenUpdating = False

With Sheets("Order Summary")
    lRow = .Cells(Rows.Count, 2).End(xlUp).Row + 1
    
    .Cells(lRow, 2).Value = ActiveSheet.Range("A5")
    .Cells(lRow, 3).Value = ActiveSheet.Range("E5")
    .Cells(lRow, 4).Value = ActiveSheet.Range("B5")
    .Cells(lRow, 5).Value = ActiveSheet.Range("D5")
    .Cells(lRow, 7).Value = ActiveSheet.Range("F5")
    .Cells(lRow, 8).Value = ActiveSheet.Range("G5")
    .Cells(lRow, 9).Value = ActiveSheet.Range("H5")
    
End With

Application.ScreenUpdating = True
End Sub

Excel Workbook
ABCDEFGH
4Data1Data2*Data3Data4Data5Data6Data7
5Test1 A5Test1 B5*Test1 D5Test1 E5Test1 F5Test1 G5Test1 H5
Prices



Excel Workbook
BCDEFGHI
3Prices A5Prices E5Prices B5Prices D5*Prices F5Prices G5Prices H5
4********
5********
6********
7********
Order Summary



*** Run the Macro CopyData***

Excel Workbook
BCDEFGHI
3Prices A5Prices E5Prices B5Prices D5*Prices F5Prices G5Prices H5
4Test1 A5Test1 E5Test1 B5Test1 D5*Test1 F5Test1 G5Test1 H5
5********
6********
7********
Order Summary


Excel Workbook
ABCDEFGH
4Data1Data2*Data3Data4Data5Data6Data7
5Test2 A5Test2 B5*Test2 D5Test2 E5Test2 F5Test2 G5Test2 H5
Prices



*** Run the Macro CopyData***

Excel Workbook
BCDEFGHI
3Prices A5Prices E5Prices B5Prices D5*Prices F5Prices G5Prices H5
4Test1 A5Test1 E5Test1 B5Test1 D5*Test1 F5Test1 G5Test1 H5
5Test2 A5Test2 E5Test2 B5Test2 D5*Test2 F5Test2 G5Test2 H5
6********
7********
Order Summary



To use the code I have provided, press alt F11 to open vba.
Click Insert, click Module and paste the code into the white area on the right. Press alt F11 to close vba.

You can Insert a Shape onto sheet Prices, Right click the shape, click Assign Macro, double click CopyData. When you click the button the code will run and copy the data from Prices to Order Summary

I hope that works for you.

Good luck.

Ak
 
Upvote 0
Hi Akashwani,

That's absolutely fantastic, thank you. I've just tested it and it works perfectly. I really do appreciate your thoughtful and thorough reply.

Rob
 
Upvote 0

Forum statistics

Threads
1,215,829
Messages
6,127,130
Members
449,361
Latest member
VBquery757

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