View Single Post
  #5   Report Post  
Metin
 
Posts: n/a
Default

Markus, thanks for your help. But when I run this macro I get an
errormessage: Run-time error '1004', Method 'Range' of object '_Global'
failed.
What this error message mean. What is going wrong.

"Markus Scheible" wrote:

Hi Metin,


-----Original Message-----
1. 'ExSh' is wrong it has to be 'wks'. wks is defined.
2. The i was a mistype. Just forgot the i and the loop.
The error is in defining the x values and the y values.
xWT = Range(rng, "WT", rng.Offset(0, v)) is wrong. With

this line I want to
select all data which is in the row where the 'WT' is

found, but 'v' columns
further. In the next line I want to use the previous

selection (with the WT)
for the x values of the chart.


Well, okay. I would do it like the following (presumed
that you just search for an explicitly known entry within
column A such as "WT"):

i = 3
For Each cell In Range("A1", "A1000")
If cell.Value = "WT" Then
ActiveChart.SeriesCollection(i).XValues = Range("C" &
cell.Rows).Value
ActiveChart.SeriesCollection(i).Values = Range("F" &
cell.Rows).Value
ActiveChart.SeriesCollection(i).Name = "whatever"
i = i + 1
End If
Next cell

Maybe change it a little bit like you need it... don't
know if it works already the way you want.

BTW: I wouldn't work with the activechart statement... try
define this chart explicitly...


P.S. Markus, do you now somebody in the Netherlands who I

can hire in to
help me with this kind of macro's and other macro's for

automatically
calculations in Excel?



Sorry, don't know, I am from Germany... maybe you can
contact one of the Excel MVPs within this newsgroup....
often they work as professional programmers.

Best

Markus

"Markus Scheible" wrote:

Hi Metin,

although I understood what you want to do, I do not
understand what your macro shall do - sorry...
nevertheless I found some errors:



Sub Testi_1()
Set wks = Worksheets("Calculated Data")

v = 2
w = 5
For i = 1 to 3
exSh.Select

What is exSh ? Is this object defined before? Otherwise
excel cannot select it.

Set rng = Range("C2:S97")
xWT = Range(rng, "WT", rng.Offset(0, v))
yWT = Range(rng, "WT", rng.Offset(0, w))
ActiveChart.SeriesCollection(3).XValues = xWT
ActiveChart.SeriesCollection(3).Values = yWT
ActiveChart.SeriesCollection(3).Name = "=""ASP
Reference samples"""

v = v + 1
w = w + 1

Within your loop you haven't used i... so it is no real
loop because it just runs once.

Maybe you wanted to use SeriesCollection(i) instead? I
don't really know...

Next

This is no close statement for a for-loop. Next must
define which variable should be used... so use "Next i".

End Sub



Maybe that helps a little bit?

Best

Markus



.