Copy and Paste specific columns

rholdren

Board Regular
Joined
Aug 25, 2016
Messages
140
Office Version
  1. 365
  2. 2019
Good morning everyone. I have a piece of code (pasted below - Excel 365) and the code works fine for the entire row. However, I became curious and started looking around and have not been able to find an answer to this: In the code below a specific value is searched for in a column C and if located copies the entire row and pastes it on another page. What I became curious about is what if I didn't want to paste the entire row. But let's say that once a matching value is found I only want to paste what shows up in that same row but only Column A, Column D, Column H, Column L and move it to another sheet. I know I can do this with using an offset and running through the code so that it moves everything over one column at a time but I just couldn't figure out a way to streamline that. I have 79 Columns in the Data worksheet which has to stay intact but I only need 12 of them to review so I was working on a quick view page where I am using dropdown comboboxes to select the value to pull over.

Sheets("Sheet1").Select

Last = Cells(Rows.Count, "C").End(xlUp).Row
For i = Last To 1 Step -1
If (Cells(i, "C").Value) = Sheets("Sheet2").Range("C2") Then

Cells(i, "C").EntireRow.Copy

Sheets("Sheet2").Select

Any help would be greatly appreciated.

Thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi,

is it worth re-arranging your data columns to be able to just cut and paste a range of the 12 columns to review ?

You could use VBA to re-arrange them ..

Rob
 
Upvote 0
Hi,

is it worth re-arranging your data columns to be able to just cut and paste a range of the 12 columns to review ?

You could use VBA to re-arrange them ..

Rob
Hi Rob, thanks for the reply.

I had already linked the needed ranges to specific rows in a hidden worksheet and use the hidden worksheet to query. I don't think I can use vba to rearrange because I am using comboboxs with linked cells and have some script that addresses those specific cells. the solution I have I have had in place for a while and it works fine but I just became curious if there was another way to move the data. The workbook is already 8mb and when I got it, it was 35mb. The current code I have doesn't increase the size much but I wanted to get the file size as small as I could since the file will be emailed back and forth. If I could script it to address the columns without having a linked worksheet that would cut the file sized down even more. I could go back and forth one column at a time using an offset but that would slow things down a bit as the source worksheet currently has over 4000 rows. No worries, thanks again for responding. Have a great day. :)
 
Upvote 0

Forum statistics

Threads
1,215,491
Messages
6,125,098
Members
449,205
Latest member
ralemanygarcia

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