how to copy and paste a DATA from one sheet to another

charith

Board Regular
Joined
Jan 3, 2014
Messages
152
hello...

i want to copy column A,D,E,F from sheet 1 to sheet 2 column B,C,D,F...

I have a sheet titled "Main" that contains the raw data like the example below. I have another sheets titled "Orders" and . I'm needing a code to copy the data only from column A,D,E,F in "Main" sheet, and paste it in the "Sheet 2" column B,C,D,F based on "sell & buy" values

Sheet(main)
ABCDEF
ORDER TYPE#ORDERSPRICE%
BUY145.780.1
SELL232354.670.15
----
BUY34567890.23

<tbody>
</tbody>

Sheet(Orders)
ABCDFG
A1BUY145.780.1
B2SELL232354.670.15
C1BUY34567890.23
D1

<tbody>
</tbody>

Any help is MUCH appreciated THANK YOU!!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
You will have to make sure the workbook names in the code are correct.

You probably have to remove the part that says Drop Box from the names and make sure all the workbook names are proper.

The code will work if the names of the workbooks are correct. I runs fine on my computer here. When I send it to you is when the names get screwed up.

Howard
 
Upvote 0
sir finally it works..!! this is the code..!!
Code:
Sub Macro4()


    Workbooks.Open ("C:\Users\charith\Google Drive\Analysis\Long & Short\Long\A.xlsx")
    Windows("A.xlsx").Activate
    Range("J65:AY65").Select
    Selection.Copy
    Windows("Portfolio for analysis.xlsx").Activate
    Range("M2").Select
    ActiveSheet.Paste Link:=True
    Range("M2").Select
    ActiveWorkbook.Save
    Windows("A.xlsx").Close
    
    Workbooks.Open ("C:\Users\charith\Google Drive\Analysis\Long & Short\Long\AA.xlsx")
    Windows("AA.xlsx").Activate
    Range("J65:AY65").Select
    Selection.Copy
    Windows("Portfolio for analysis.xlsx").Activate
    Range("M3").Select
    ActiveSheet.Paste Link:=True
    Range("M3").Select
    ActiveWorkbook.Save
    Windows("AA.xlsx").Close
    
    Workbooks.Open ("C:\Users\charith\Google Drive\Analysis\Long & Short\Long\ADBE.xlsx")
    Windows("ADBE.xlsx").Activate
    Range("J65:AY65").Select
    Selection.Copy
    Windows("Portfolio for analysis.xlsx").Activate
    Range("M4").Select
    ActiveSheet.Paste Link:=True
    Range("M4").Select
    ActiveWorkbook.Save
    Windows("ADBE.xlsx").Close
    
    Workbooks.Open ("C:\Users\charith\Google Drive\Analysis\Long & Short\Long\ALXN.xlsx")
    Windows("ALXN.xlsx").Activate
    Range("J65:AY65").Select
    Selection.Copy
    Windows("Portfolio for analysis.xlsx").Activate
    Range("M5").Select
    ActiveSheet.Paste Link:=True
    Range("M5").Select
    ActiveWorkbook.Save
    Windows("ALXN.xlsx").Close
sir can't we use a loop to open these files. like this ..!!

Dim i As Long
i = 3
Dim wbk As Workbook
Dim Filename As String
Dim Path As String
Path = "C:\Users\Analysis\Long & Short\Long\"
Filename = Dir(Path & "*.xlsx")




'-----------------------------<wbr>---------------
'OPEN EXCEL FILES IN FOLDER
Do While Len(Filename) > 0 'IF NEXT FILE EXISTS THEN
Set wbk = Workbooks.Open(Path & Filename)
''''''''''''''''''''''''''''''<wbr>'''''''''''''''''''''''''''''
'''''''''''''''Open Files '''''''''''''''''''''''''
With ActiveWorkbook
If Not IsEmpty(.LinkSources(<wbr>xlExcelLinks)) Then
For Each link In .LinkSources(xlExcelLinks)
.BreakLink link, xlLinkTypeExcelLinks
Next link
End If
End With

thank you very much
 
Upvote 0
sir this code is working...!!
Code:
Sub Macro4()


    Workbooks.Open ("C:\Users\charith\Google Drive\Analysis\Long & Short\Long\A.xlsx")
    Windows("A.xlsx").Activate
    Range("J65:AY65").Select
    Selection.Copy
    Windows("Portfolio for analysis.xlsx").Activate
    Range("M2").Select
    ActiveSheet.Paste Link:=True
    Range("M2").Select
    ActiveWorkbook.Save
    Windows("A.xlsx").Close
    
    Workbooks.Open ("C:\Users\charith\Google Drive\Analysis\Long & Short\Long\AA.xlsx")
    Windows("AA.xlsx").Activate
    Range("J65:AY65").Select
    Selection.Copy
    Windows("Portfolio for analysis.xlsx").Activate
    Range("M3").Select
    ActiveSheet.Paste Link:=True
    Range("M3").Select
    ActiveWorkbook.Save
    Windows("AA.xlsx").Close
End  sub
 
Upvote 0
Last edited:
Upvote 0
With this copy of long, it may open as "Copy of long (1)"

If it does, then do a Save As and save as "long" only, no quotes.

Then it should work with the Book A & AA.

Howard
 
Upvote 0
hii sir i need a big help from you..




i want to copy last prices to exit prices , only when SIGNAL = S,
but at the beginning SIGNAL column = empty after some time , if any cell in that column become "S" THEN copy the last prices to exit prices


beginning
HIGH PRICELAST PRICESIGNALEXIT PRICE
1278
5634
3456

<tbody>
</tbody>

After some time
HIGH PRICELAST PRICESIGNALEXIT PRICE
1278
5634S34
3456

<tbody>
</tbody>



HIGH PRICELAST PRICESIGNALEXIT PRICE
1278S78
5634S34
3456

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,216,126
Messages
6,129,021
Members
449,480
Latest member
yesitisasport

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