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!!
 
Copy this to a Standard Module, not the sheet module. I used a Forms button with the Sub TenSec() assigned to it.

The button needs to be on the sheet you want the copy code to run on.

So, if you had a button on three different sheets and TenSec was assigned to each button, the code would work on the sheet of the button clicked and not the other two.

This may not be in best practice of coding. Maybe one of the pros will chime in and make a suggestion.

Howard

Code:
Option Explicit

Sub TenSec()
 'Runs a macro 10 seconds after button click.

Application.OnTime Now + TimeValue("00:00:10"), "AcolToBcol"

End Sub

Sub AcolToBcol()
Dim c As Range
Dim Lc As Long, lr As Long
Dim Brng As Range
Dim lColumn As Long

lr = Cells(Rows.Count, 2).End(xlUp).Row
Set Brng = Range("B1:B" & lr)

For Each c In Brng
  
  If c <> "" Then
     c.Copy c.Offset(, -1)
  End If
  
Next

End Sub
Thank you very much for your code sir
i tried like this .. but it didn't work..!! :(

https://www.dropbox.com/s/hrfsh4fy7hbdzif/test.xlsx
 
Upvote 0

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Sir if i want to copy Column B (2)("Main sheet") -> Column A (1)("Order sheet") AND Column AV(48)("Main sheet") -> Column E(5)("Order sheet")

what are the changes that i have to done in this code

Sub BuyCells()
Dim c As Range
Dim ceBySel As Range
Dim lr As Long


lr = Cells(Rows.Count, 83).End(xlUp).Row
Set ceBySel = Range("CE6:CE" & lr)


Application.ScreenUpdating = False


For Each c In ceBySel


If c = "BUY" Or c = "SELL" Then
c.Resize(1, 3).Copy
Sheets("Orders").Range("B" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

End If


Next
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Add this line just below the other one in the code you posted.


Code:
  c.Offset(, -35).Copy
         Sheets("Orders").Range("E" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

Also, I think it's time for you to learn to use code tags when you post code to the forum.
It make it much easier to read and preserves the spaces etc.

Just type in Code in the brackets as shown and type or copy your code between the bracketed code words.
I've added space so it will not compile. When you use the code tags type with NO spaces and it will look like the code I posted above.

[ code ] Your code goes here [ /code ]

Howard
 
Last edited:
Upvote 0
Add this line just below the other one in the code you posted.


Code:
  c.Offset(, -35).Copy
         Sheets("Orders").Range("E" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

Also, I think it's time for you to learn to use code tags when you post code to the forum.
It make it much easier to read and preserves the spaces etc.

Just type in Code in the brackets as shown and type or copy your code between the bracketed code words.
I've added space so it will not compile. When you use the code tags type with NO spaces and it will look like the code I posted above.

[ code ] Your code goes here [ /code ]

Howard

Thank you very much sir, it works :) :)
 
Upvote 0
sir,
i have a small problem in these two columns

when the market starts, some current prices are loaded to this sheet with few minutes delay (sometimes it late more than 2 minutes),those prices are representing -1 ([1.00]) <- this is not the actual price

Open priceCurrent Price
123.56
[1.00]
1245.78
789.45

<tbody>
</tbody>
once i pressed the "GET OPEN PRICE" button it will copy the "current price " data to " open price " after 10 seconds ,like this ..
Open priceCurrent price
123.56123.56
1.00[1.00]
1245.781245.78
789.45789.45

<tbody>
</tbody>

so what i want is when there is a data in "Current price" column which = [1.00] ,then do not copy that data to "Open price"

Open priceCurrent Price
123.56123.56
[1.00]
1245.781245.78
789.45789.45

<tbody>
</tbody>

so once it changed from [1.00] to another value , then copy to "open price"

Open priceCurrent Price
123.56123.56
345.69345.69
1245.781245.78
789.45789.45

<tbody>
</tbody>


Sir, can you please help me to do that..!!

Thank you very much..!!
 
Upvote 0
Post a link to your most recent workbook example please.

Along with the columns you want copies from and to with the 10 second delay code.

Howard
 
Upvote 0

Forum statistics

Threads
1,216,110
Messages
6,128,896
Members
449,477
Latest member
panjongshing

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