Help me edit my macro to copy cell range!

gcr114

New Member
Joined
Jul 8, 2011
Messages
3
Hello everyone!

So what I need my macro to do is search through a sheet, find a value, and copy cells in Column A and Column C and paste them into a new sheet. This code works fine except for the copy part. I can make it copy the whole row but not the invidividual Cells in A or C. Any help is appreciated!

Code:
Public Sub Copy()
 
Sheets("Sheet1").Select
 
FinalRow = Range("A10").End(xlUp).Row
 
For x = 2 To FinalRow
 
ThisValue = Range("C" & x).Value
 
If ThisValue = "AA" Then
 
Range("A" & x).Copy 
Sheets("Sheet2").Select
NextRow = Range("A10").End(xlUp).Row + 1
Range("A" & NextRow).Select
ActiveSheet.Paste
Sheets("Sheet1").Select
ElseIf ThisValue = "B" Then
 
Range("A" & x & ":AG" & x).Copy 
Sheets("Sheet2").Select
NextRow = Range("A10").End(xlUp).Row + 1
Range("A" & NextRow).Select
ActiveSheet.Paste
Sheets("Sheet1").Select
 
 
End If
Next x
End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try like this

Code:
Union(Range("A" & x), Range("C" & x)).Copy


This worked! Thank you very much!

Just one more question, is there a way to code is so that the information from Column C on Sheet1 goes into Column A on Sheet2 and the info from Column A on Sheet1 goes into Column B on Sheet2?
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,391
Members
452,909
Latest member
VickiS

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