Excel macro offset

ApolloID

Well-known Member
Joined
Jun 8, 2010
Messages
769
Hi, i have this part of a code:

ActiveChart.SetSourceData Source:=Range( _
"'Sheet1'!$E$4:$P$4,'Sheet1'!$E$5:$P$5")
and i need this part to be:

ActiveChart.SetSourceData Source:=Range( _
"'Sheet1'!$E$4:$P$4,'Sheet1'!activerange.select.offset(3.0)")

Can this be done?

Thanks!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
What is activerange variable? May be ActiveCell?
 
Upvote 0
Found on google, not tested, just edited to your range.

Code:
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range _
        ("E4:P4", ActiveCell.Offset(3))
 
Upvote 0
Hi, i put a piece of the code...this is the entire code:
Code:
Sub Macro2()
    Range("E4:P4,E5:P5").Select
    Range("P5").Activate
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.SetSourceData Source:=Range( _
        "'Sheet1'!$E$4:$P$4,'Sheet1'!$E$5:$P$5")
    ActiveChart.ChartType = xlLineMarkers
End Sub

I need this code to loop until last filled row, and to insert a chart from 3 to 3 rows.
But the second part of the range to be everytime with 3 rows below.

Can this be done?
Thanks in advance!
 
Upvote 0
How can i name a range?

My range is : Range("E4:P4,E5:P5").Select

I need to refer to range as "range1" or any other name.
 
Upvote 0
Thanks.

how can i add offset to the second range (offset only for E5:P5?)

Set myrange = Range("E4:P4,E5:P5")

to something like this?

Set myrange = Range("E4:P4,((E5:P5).offset(3,0))")

Thanks!
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,917
Members
452,949
Latest member
beartooth91

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