Copying Selected Cells

superg

New Member
Joined
Jan 20, 2005
Messages
24
Ok another one to keep you guys occupied lol. Im tryin g to select mulitple cells on the one sheet and transfer them to another, this code is a basic code just to show you what cell numbers i am trying to copy.

Sheets("Entry Data").Range("B12, L12, B16, B19, L19, B23, L23, B27").Copy Sheets("All Tray Data").Range("A2:A9")
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
It might not be very efficient, but something like this should work:

Code:
Sub CopyMultipleRanges()
sToCopy = Array("B12", "L12", "B16", "B19", "L19", "B23", "L23", "B27")
sToPaste = Array("A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9")

For n = LBound(sToCopy) To UBound(sToCopy)
    Sheets("Entry Data").Range(sToCopy(n)).Copy Sheets("All Tray Data").Range(sToPaste(n))
Next n
End Sub
 
Upvote 0
Very neat:

Another (less sophisticated) option:
Sub Macro3()
Dim cell As Range

Sheets("Entry Data").Select
Range("B12, L12, B16, B19, L19, B23, L23, B27").Select
For Each cell In Selection
cell.Copy
Sheets("All Tray Data").Activate
ActiveCell.Offset(1, 0).Activate
If ActiveCell.Row < 2 Then Range("A2").Activate
ActiveSheet.Paste
Next cell
End Sub
 
Upvote 0
this is the thing that im doing at the moment

Private Sub CommandButton1_Click()

Worksheets("Entry Data").Range("b12").Copy _
Destination:=Worksheets("All General Data").Range("A2")
Worksheets("Entry Data").Range("l12").Copy _
Destination:=Worksheets("All General Data").Range("B2")
Worksheets("Entry Data").Range("b16").Copy _
Destination:=Worksheets("All General Data").Range("C2")
Worksheets("Entry Data").Range("b19").Copy _
Destination:=Worksheets("All General Data").Range("D2")
Worksheets("Entry Data").Range("l19").Copy _
Destination:=Worksheets("All General Data").Range("E2")
Worksheets("Entry Data").Range("b23").Copy _
Destination:=Worksheets("All General Data").Range("f2")
Worksheets("Entry Data").Range("l23").Copy _
Destination:=Worksheets("All General Data").Range("G2")
Worksheets("Entry Data").Range("b27").Copy _
Destination:=Worksheets("All General Data").Range("H2")
End Sub

This pushes a button then copies all of the cells i want into the sheet i want, the next thing i want to do is when all of these are entered, the next lot of these cells must go underneath the previous lot, thanks.
 
Upvote 0
How about this (your macro adjusted to make the row dynamic):

Private Sub CommandButton1_Click()
RowNumber = Worksheets("All General Data").[a65536].End(xlUp).Offset(1, 0).Row
Worksheets("Entry Data").Range("b12").Copy _
Destination:=Worksheets("All General Data").Range("A" & RowNumber)
Worksheets("Entry Data").Range("l12").Copy _
Destination:=Worksheets("All General Data").Range("B" & RowNumber)
Worksheets("Entry Data").Range("b16").Copy _
Destination:=Worksheets("All General Data").Range("C" & RowNumber)
Worksheets("Entry Data").Range("b19").Copy _
Destination:=Worksheets("All General Data").Range("D" & RowNumber)
Worksheets("Entry Data").Range("l19").Copy _
Destination:=Worksheets("All General Data").Range("E" & RowNumber)
Worksheets("Entry Data").Range("b23").Copy _
Destination:=Worksheets("All General Data").Range("f" & RowNumber)
Worksheets("Entry Data").Range("l23").Copy _
Destination:=Worksheets("All General Data").Range("G" & RowNumber)
Worksheets("Entry Data").Range("b27").Copy _
Destination:=Worksheets("All General Data").Range("H" & RowNumber)
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,479
Members
448,967
Latest member
visheshkotha

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