Macro for finding the amount of rows that contain data

Ljb12668

New Member
Joined
Jul 20, 2003
Messages
4
I have written a macro to automatically create a graph from data i have input into column D. The problem is I dont always have the same amount of data entries in this column. Can someone help me find a way to automatically search column d for data so I can input that value automatically into my range field so my graph will be correct.

Example. My graph works fine if I know how many rows of data I have such as range(d1:d20) but if the next time there are 200 rows of data, I am in trouble. I need a macro to look down column d and put the last row that contains data into my range value. Any help would be greatly appreciated.

Thanks
 

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.
Hi Lbj12668:

Welcome to the Board!

Setting up a Dynamic Range for your chart is the prefered way to go, as EliW has stated in his post.

However if you want to find the Number of Rows in Column D, one of the ways to do that would be use
Code:
NumberOfRows=worksheetfunction.counta([D:D])
so if you had data in rows 1 through 8, the code will give you 8.

If I have misunderstod your question, my apologies!
 
Upvote 0

Forum statistics

Threads
1,215,329
Messages
6,124,302
Members
449,150
Latest member
NyDarR

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