moramramesh
New Member
- Joined
- May 22, 2019
- Messages
- 17
I have the below code:
Range("A:A,B:B,C:C,D:D,E:E,F:F,G:G,H:H,I:I").Select
Range("I1").Activate
ActiveSheet.Shapes.AddChart2(227, xlLine).Select
ActiveChart.SetSourceData Source:=Range("Sheet2!$A1:$I$" & lr2)
Since I know that data is available from columns A to I, I have passed all the columns in the range function. But I would like to pass range value dynamically based on the last column containing data.
Accordingly in the 2nd line, I want pass the last column first cell instead of Range("I1").Activate
Similarly in the 4th line, I want to pass dynamic column value in place of I, instead of Range("Sheet2!$A1:$I$" & lr2)
Range("A:A,B:B,C:C,D:D,E:E,F:F,G:G,H:H,I:I").Select
Range("I1").Activate
ActiveSheet.Shapes.AddChart2(227, xlLine).Select
ActiveChart.SetSourceData Source:=Range("Sheet2!$A1:$I$" & lr2)
Since I know that data is available from columns A to I, I have passed all the columns in the range function. But I would like to pass range value dynamically based on the last column containing data.
Accordingly in the 2nd line, I want pass the last column first cell instead of Range("I1").Activate
Similarly in the 4th line, I want to pass dynamic column value in place of I, instead of Range("Sheet2!$A1:$I$" & lr2)