Macro to copy and paste non-contiguous cell

jgrant999

New Member
Joined
May 7, 2018
Messages
1
I am trying to create a macro to copy only cell in 3 columns that have data. I have the macro working in one of the columns but if I try one to the left or all three in a range it doesn't select properly and am unable to proceed.

I use this and it works fine.

'Copy Cost Codes and Qty as Text Values'
Sheets("18001 Cap Sheet").Select
LR = Range("L" & Rows.Count).End(xlUp).Row
Range("L9:N" & LR).Copy
Range("V9:X" & LR).PasteSpecial xlPasteValues
Application.CutCopyMode = False




'Select Revenue Values and Move to Job Cost Contract Items Sheet'
Sheets("18001 Cap Sheet").Select
LR = Range("L" & Rows.Count).End(xlUp).Row
Range("x9:x" & LR).SpecialCells(xlCellTypeConstants, 23).Select
Selection.Copy
Sheets("Job Cost Contract Items").Select
Range("K5").Select
ActiveSheet.Paste

what I want to do is this:

'Copy Cost Codes and Qty as Text Values'
Sheets("18001 Cap Sheet").Select
LR = Range("L" & Rows.Count).End(xlUp).Row
Range("L9:N" & LR).Copy
Range("V9:X" & LR).PasteSpecial xlPasteValues
Application.CutCopyMode = False




'Select Revenue Values and Move to Job Cost Contract Items Sheet'
Sheets("18001 Cap Sheet").Select
LR = Range("L" & Rows.Count).End(xlUp).Row
Range("v9:x" & LR).SpecialCells(xlCellTypeConstants, 23).Select
Selection.Copy
Sheets("Job Cost Contract Items").Select
Range("i5").Select
ActiveSheet.Paste

when I change it to the range that includes all 3 columns it's selecting it funny and not just non contiguous cells in the first 2 columns.

Even if I just try v or w, then it's the same thing and selecting the entire range and not just cells that have data.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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