Select all data in a column

excelcraze

Board Regular
Joined
Sep 10, 2012
Messages
81
Hello,

I use the following code to select all data in a column. In my example data available only in two cells (M8 and M9). When I used the following code it selects from M1 to M9.

Sometimes I may have one or many data.

Code:
 Range(Selection, Selection.End(xlDown)).Select
 Range(Selection, Selection.End(xlUp)).Select

Please help

I am using Win 7, Office 2013
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hello,

I use the following code to select all data in a column. In my example data available only in two cells (M8 and M9). When I used the following code it selects from M1 to M9.

Sometimes I may have one or many data.

Code:
 Range(Selection, Selection.End(xlDown)).Select
 Range(Selection, Selection.End(xlUp)).Select

Please help

I am using Win 7, Office 2013
Instead of showing us code that doesn't work all by itself, why don't you tell us about the data setup (what you have AND what you could possibly have) in Column M. For example... Is M1 a header cell with text in it? Can M2 have data in it also? Will the starting selected cell always be M1? Can there be blank cells between the data in Column M and, if yes, do you want those blank cells selected along with the data cells or do you only want the non-contiguous data cells selected by themselves? Etc. Also you should know that it is very rare indeed that you need to select any cells in order to work with them and usually not selecting things beforehand makes the code easier to work with. To that end, in addition to telling us about the layout of your data, if you tell us what you are ultimately attempting to do with it (that is, what was to come next had the selections you indicated you attempted to make actually worked), then we can show you how to proceed.
 
Upvote 0
Okay.
Here is what I want.

Data what I want to copy is always starts from M8. Number of data may vary (it can even be only one). These cells to be copied and paste in D8.

Thanks.
 
Upvote 0
Okay.
Here is what I want.

Data what I want to copy is always starts from M8. Number of data may vary (it can even be only one). These cells to be copied and paste in D8.
Does this single line of code do what you want?

Code:
Range("M8", Cells(Rows.count, "M").End(xlUp)).Copy Range("D8")
 
Upvote 0
Fabulous.
I wanted to cut instead of copy. So I replaced Copy with Cut in your code.

Thanks.

Edit:

There are a couple of other question I posted today, can you please take a look at that?
 
Upvote 0

Forum statistics

Threads
1,215,579
Messages
6,125,646
Members
449,245
Latest member
PatrickL

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