Hello I am making a macros to plot some data, the point is to receive from the user two columns to plot, i tried first getting this values with two input boxes:
first = InputBox("first column", "Enter a Column")
two = InputBox("second column", "Enter a Column")
The problem with this approach is that i have to do the following in order to plot:
Set rng = .Range(first + "2:" + first + "84," + two + "2:" + two + "84")
The idea is to receive the value to then concatenate it with the "2" and "84" that are my range, I would like to make this macros more flexible since i am always using the same range from 2 to 84, i don't understand very well active columns, I would like to appreciate any suggestion to overcome this situation, my complete code looks as follows:
Sub ALL()
Dim ws As Worksheet
Dim rng As Range
Dim objChrt As ChartObject
Dim chrt As Chart
Set ws = ThisWorkbook.Sheets("DATA")
With ws
first = InputBox("first column", "Enter a Column")
two = InputBox("second column", "Enter a Column")
Set rng = .Range(first + "2:" + first + "84," + two + "2:" + two + "84")
.Shapes.AddChart
Set objChrt = .ChartObjects(.ChartObjects.Count)
Set chrt = objChrt.Chart
With chrt
.ChartType = xlColumnClustered
.SetSourceData Source:=rng
End With
End With
End Sub
Set rng = Application.InputBox(prompt:="Select a cell", Type:=8)msdn.microsoft.com/en-us/library/office/….SetSourceData Source:=Selection