Problem ofsetting a selection

richanor

Active Member
Joined
Apr 8, 2006
Messages
291
Hi all

I have a piece of code which will find a data range within a worksheet and make me a bar chart of it:

Code:
Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Offset(-1, -1).Activate
    Charts.Add
    ActiveChart.ChartType = xlColumnClustered
    ActiveChart.Location Where:=xlLocationAsObject, Name:="pivot cash"
    With ActiveChart
        .HasTitle = False
        .Axes(xlCategory, xlPrimary).HasTitle = False
        .Axes(xlValue, xlPrimary).HasTitle = False
    End With

(this is not the entire code)...

My problem is that once I have selected the "block" of data which I want to be the source data for my chart, I want to reduce the data range by 1 column and 1 row (to cut off the totals). The code I have patched together above just moves the selection rather than reduces it.

Any help ammending this would be most appreciated.

Rich
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Replace the first 3 lines with :-

Code:
Range(Selection, Selection.End(xlToRight)(1, 0)).Select
Range(Selection, Selection.End(xlDown)(0)).Select
 
Upvote 0
Thanks a lot - that worked a treat. Do you know if it's possible to specify the size / location of the chart excel is creating? If so could you point me in the direction of any info regarding this.

Thanks again

Rich
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,413
Members
449,082
Latest member
tish101

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