Dynamic range help

Gromace

New Member
Joined
Jan 11, 2011
Messages
15
Hello,

I have the following code in a macro, in Excel 2007.

Range("M5").Select
Selection.Copy
Range("M5:M18264").Select
ActiveSheet.Paste


I currently have over 18,000 cells in the range, but the exact number will change monthly. What is the most effective way to select my range, without knowing the exact number of cells? Is there a function that can do this? If column A contains data, I want to include that row number in the range.

Thanks in advance for your help!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
First, you dont have to select a range to do Copy or Paste,

Code:
Range("M5:M" & Range("A" & Rows.Count).End(xlUp).Row).FillDown
 
Upvote 0
Sankar,

Thank you for your quick response! Your suggestion worked in place of the code I posted, but I have one other request. Could you explain what is going on with your code? That would help me learn it and understand what is going on. I also have similar code that I need to modify. Once I have completed the filldown, I would like to select the entire row and copy, pastespecial value. Can I use the same type of code you suggested?

Thanks again!

Gromace
 
Upvote 0

Forum statistics

Threads
1,222,383
Messages
6,165,656
Members
451,983
Latest member
Raph24

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