Copy selected items to a contiguous list ion another worksheet

Michael Jones

New Member
Joined
Jul 15, 2014
Messages
19
I am attenmpting to copy selected items in one worksheet to another, but require the copied list to be contiguous, no spaces. I have searched other posts and attempted various formulae, but without success. Does anyopne out there have a solution for me?

Thank you all in advance for any suggestions:confused:
 
Last edited:

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Try this script:
Assuming selected items means selected Range of cells.


So on the sheet where you want to run this script from select a range
Then this script will copy all cells with values into Sheet(2) column A
Modify script if needed to your needs or give more specific details.

Code:
Sub Test()
'Modified 5/10/2018 4:40 AM  EDT
Application.ScreenUpdating = False
Dim c As Range
Dim i As Long
i = 1
    For Each c In Selection
        If c.Value <> "" Then Sheets(2).Cells(i, 1).Value = c.Value: i = i + 1
        Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Or if you need to copy the cells which copies formatting also thy this:
Code:
Sub Test()
'Modified 5/10/2018 4:47 AM  EDT
Application.ScreenUpdating = False
Dim c As Range
Dim i As Long
i = 1
    For Each c In Selection
        If c.Value <> "" Then c.Copy Sheets(2).Cells(i, 1): i = i + 1
    Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Re: Copy selected items to a contiguous list in another worksheet

Many thanks for your prompt response. This appears to be just what I am looking for.


I will try this out later and let you know how I get on


Michael
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,202
Members
448,554
Latest member
Gleisner2

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