Using cell to locate and copy table cells and paste to another location

richard12

New Member
Joined
Feb 9, 2017
Messages
23
I am using Excel 2016. The code fails in a VBA Macro I am trying to develop. The Macro was developed with Record Macro, then changed a little.

My object is to use a cell "U2" to find a row in a table by filtering using the cell data. That works, I can see the results hovering over the "U2" .Value.
Code:
Range("U2").Select  Selection.Copy
  ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=1, Criteria1:=Range("U2").Value

Using the results to copy the two row cell data is coded as:

Code:
Range("I214:J214").Select
    Application.CutCopyMode = False
    Selection.Copy

However, when hovering over the Range, nothing is copied. I don't want those cells as they are from a previous selection and were hard coded into the Macro. Is there a way to go to a row and select 2 cells in that row?

The range was obtained as I manually filtered while recording the Macro, then selected and copied the two cells and that worked. I was able to manually paste the cells to another 2 cells on the sheet while I recorded, but not with VBA. I don't know how to go to the same row as the "U2" data and copy the row cell data using VBA.
 
Last edited:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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