Urgent Macro help

  • Thread starter Thread starter Yeshwin
  • Start date Start date
Y

Yeshwin

Hi All,

Please Need help.

I have a function below that needs to be twicked so that i can use it.

I am trying to apply the second row valuse to the datalables. Can some one
please give me a simpler version of this function so that I can impliment it
and understand as to what is happening so that i can learn from it.

Sub customdatalabels(ActiveChart, columns, measures)
Dim r
Dim c
Dim val
Set rval = False
For r = 1 To r <= measures

For c = 1 To c <= columns
val = Activesheet.Range(col(c) + (r + 1)).Value
If (val <> undefined & val <> "") Then
rval = True
If (ActiveChart.PlotBy = 2) Then

ActiveChart.SeriesCollection.Item(c).Points.Item(r).DataLabel.Text = val
Else

ActiveChart.SeriesCollection.Item(r).Points.Item(c).DataLabel.Text = val
Datasheet.Rows.Item(r + 2).Delete
rval

End Sub

What I understan is that I am looping through the columns and rows and then
going to the send row and getting the valuse for each column and then
appling that to the datalable.


Now I also see that there is reference to col which seems to be an external
function that reads the column names like A, B, C etc...


I was wondering if some one cna give an work around this so that I do not
have to use that external function col and still reference the columns in a
way that i can use them in the function above.


Any and All help will be very much appreciated.

Thanks a bunch folks for being there

Yesh
 
Hello Yesh,

It looks like the code is extracting the value of a single cell within
the Range. Change your code to this...

val = Activesheet.Cells(r+ 1, c ).Value

It doesn't need to be reconverted into "A1" format.

Sincerely,
Leith Ross
 
Sub customdatalabels(ActiveChart, columns, measures)
Dim r
Dim c
Dim val
Set rval = False
For r = 1 To measures

For c = 1 To columns
val = Activesheet.Cells(r+1,c).Value
If (val <> undefined & val <> "") Then
rval = True
If (ActiveChart.PlotBy = 2) Then

ActiveChart.SeriesCollection.Item(c).Points.Item(r).DataLabel.Text = val
Else

ActiveChart.SeriesCollection.Item(r).Points.Item(c).DataLabel.Text = val
Datasheet.Rows.Item(r + 2).Delete
rval

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top