scottscott
Programmer
I am trying to write a macro which will plot data from a text file. The data which i am trying to plot is in column B and it contains both x&y values:
B
x1
y1
x2
y2
The number of data points will always be different. I currently know the starting and ending points, but i am having trouble creating the the x and y ranges. Here is my first attempt where l1 is the starting row and l2 is the ending row:
Set x1 = Worksheets(ws).Range("B" & l1)
Set y1 = Worksheets(ws).Range("B" & l1 + 1)
For i = l1 + 2 To l2 - 1 Step 2
Set x1 = Union(x1, Worksheets(ws).Range("B" & i))
Worksheets(ws).Cells(6, 1).Value = x1
Set y1 = Union(y1, Worksheets(ws).Range("B" & i + 1))
Next i
I am having trouble adding a single element to a range. Is it possible to add a single element to an range? If so how would i accomplish this task? Is there a better method for plotting these graphs?
B
x1
y1
x2
y2
The number of data points will always be different. I currently know the starting and ending points, but i am having trouble creating the the x and y ranges. Here is my first attempt where l1 is the starting row and l2 is the ending row:
Set x1 = Worksheets(ws).Range("B" & l1)
Set y1 = Worksheets(ws).Range("B" & l1 + 1)
For i = l1 + 2 To l2 - 1 Step 2
Set x1 = Union(x1, Worksheets(ws).Range("B" & i))
Worksheets(ws).Cells(6, 1).Value = x1
Set y1 = Union(y1, Worksheets(ws).Range("B" & i + 1))
Next i
I am having trouble adding a single element to a range. Is it possible to add a single element to an range? If so how would i accomplish this task? Is there a better method for plotting these graphs?