Copy Cell To Another Workbook Sheet

DCBUS

New Member
Joined
May 22, 2015
Messages
34
Hello,
I am using the below Macro to copy Colomn "C" in sheet1 to Column "D" in sheet 2. I was wondering if it is possible instead of having predetermined copy and paste columns, that I can specify when the Macro is run. Meaning when I run the Macro, I get a dialog box that pops up that allows me to enter the sheet1 column for copy and once I enter that column, the next box pops up for me to enter the sheet2 destination column?

Code:
Option Explicit

Sub CtoD()
Dim wsOne As Worksheet, wsTwo As Worksheet
Dim arrOne, arrTwo, j As Long, jj As Long
Dim lrOne As Long, lrTwo As Long
Set wsOne = Worksheets("Sheet1")
Set wsTwo = Worksheets("Sheet2")


lrOne = wsOne.Cells(Rows.Count, "A").End(xlUp).Row
lrTwo = wsTwo.Cells(Rows.Count, "A").End(xlUp).Row


arrOne = wsOne.Range("A1:C" & lrOne).Value2
arrTwo = wsTwo.Range("A1:D" & lrTwo).Value2


For j = LBound(arrOne) To UBound(arrOne)
        For jj = LBound(arrTwo) To UBound(arrTwo)
            If arrTwo(jj, 1) = arrOne(j, 1) Then
                arrTwo(jj, 4) = arrOne(j, 3)
            End If
        Next jj
Next j
wsTwo.Range("A1").Resize(UBound(arrTwo), 4).Value = arrTwo


End Sub

Thanks Jr
 
Hello,
I would be glad to donate. Can you please send me the link so I send the funds to the correct place. I am glad to do this as my mom died of cancer, so it is very close to my heat. Thank you very much.
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,215,336
Messages
6,124,330
Members
449,155
Latest member
ravioli44

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