Macro to Copy non-congruent Cells to congruent Cells

FrankMcNally

Board Regular
Joined
Nov 14, 2014
Messages
71
Hey,

What is the Code for Copying Cells: A1 and C1 from Sheet 1 to A1 and B1 on Sheet 2 in one command? By one Command I mean rather than:
Code:
Sheets(Sheet1).Range(A1).Value.Copy
Sheets(Sheet2).Range(a1).paste
Sheets(Sheet1).Range(c1).Value.Copy
Sheets(Sheet2).Range(b1).Paste

I actually need to copy them from one Workbook to another, but one problem at a time;)
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi Frank

Try:

Code:
Worksheets("Sheet1").Range("A1,C1").Copy Destination:=Worksheets("Sheet2").Range("A1")
 
Upvote 0
That's kind of what I was doing (See Code Below), but my results pasted all three cells. I just decided to do one at a time, which is O.K. for this purpose, I just have to make the entries six times:LOL:
Code:
                    Range("A" & CDR_Count, "C" & CDR_Count).Copy                    Sheets("Sheet2").Range("A" & CDR_Count).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                :=True, Transpose:=False
 
Upvote 0
That's kind of what I was doing (See Code Below) ...

No, what you were doing is completely different.

Code:
Range("A1","J1")

means all the cells between A1 an J1, in this case 10 cells (A1,B1,C1,...J1)

whilst

Code:
Range("A1,J1")

means 2 cells, the cell A1 and the cell J1.
 
Upvote 0
O.K. but if I this theory: Range("A1,J1") the how do I use it with my variable 'CDR_Count'?

Range("A&CDR_Count, C&CDR_Count")

Thanks
 
Upvote 0
Hi

This is a simple example, using your code modified

Code:
Sub Test()
Dim CDR_Count As Long

CDR_Count = 3

Worksheets("Sheet1").Range("A" & CDR_Count & ",C" & CDR_Count).Copy
Worksheets("Sheet2").Range("A" & CDR_Count).PasteSpecial Paste:=xlPasteValues
                
End Sub
 
Upvote 0
O.K. Excellent!! I'm kind of a try-fail programmer, I understand it but I'm not great at getting all the Logic. It didn't even cross my mind that the '&' was separating the CDR_Count variable, I thought it was part of putting the CDR_Count variable into the Cell???;)

Thanks again.
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,823
Members
449,049
Latest member
cybersurfer5000

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