ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I highlight all the context area? (https://www.excelbanter.com/excel-discussion-misc-queries/17573-how-do-i-highlight-all-context-area.html)

Le9569

How do I highlight all the context area?
 
Hello,

I do have a macro that let user select an excel file and create a chart.
However, I am unable to run the chart without knowing the number of rows in
the worksheet.

Here is what I have:

ActiveChart.SetSourceData Source:=Sheets("Sheet1"). _
Range("A1:C374"), PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsNewSheet, Name:="Chart1"

The Range("A1:C374") is changing based on the file. How do I get those
dynamically?

Thanks.
le9569


Gary Brown

Try
Activesheet.usedrange
HTH,
Gary Brown

"Le9569" wrote:

Hello,

I do have a macro that let user select an excel file and create a chart.
However, I am unable to run the chart without knowing the number of rows in
the worksheet.

Here is what I have:

ActiveChart.SetSourceData Source:=Sheets("Sheet1"). _
Range("A1:C374"), PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsNewSheet, Name:="Chart1"

The Range("A1:C374") is changing based on the file. How do I get those
dynamically?

Thanks.
le9569


Le9569

Thank you.

"Gary Brown" wrote:

Try
Activesheet.usedrange
HTH,
Gary Brown

"Le9569" wrote:

Hello,

I do have a macro that let user select an excel file and create a chart.
However, I am unable to run the chart without knowing the number of rows in
the worksheet.

Here is what I have:

ActiveChart.SetSourceData Source:=Sheets("Sheet1"). _
Range("A1:C374"), PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsNewSheet, Name:="Chart1"

The Range("A1:C374") is changing based on the file. How do I get those
dynamically?

Thanks.
le9569



All times are GMT +1. The time now is 12:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com