There are at least 3 ways to do this. One, you can refer to your sheets with the static sheet number name that you will see in the VBAProject pane in the VBE. Two, you can enter the formula
=RIGHT(CELL("filename"),LEN(CELL("filename"))-SEARCH("]",CELL("filename"))) in any cell to have the current sheet tab name appear, and refer to that cell's value in your code. Or 3, you can use ActiveSheet.Name in your code.
Any help?
Tom Urtis
Here is my Code. Any suggestions
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Worksheets.ActiveSheet.Name.ChartObjects(1).Chart.Axes(xlValue)
.MinimumScale = Worksheets.ActiveSheet.Name.Range("M11").Value
.MaximumScale = Worksheets.ActiveSheet.Name.Range("N11").Value
End With
End Sub
Sorry Any other suggestions
Here is my code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Worksheets.ActiveSheet.Name.ChartObjects(1).Chart.Axes(xlValue)
.MinimumScale = Worksheets.ActiveSheet.Name.Range("M11").Value
.MaximumScale = Worksheets.ActiveSheet.Name.Range("N11").Value
End With
End Sub
Re: Sorry Any other suggestions
If your writing code in the code modules behind a worksheet (as you seem to be below) you could use the Me keyword. That would refer to the worksheet itself.
eg Me.Range("a1").Value="Test"
Gary
Re: Sorry Any other suggestions
Here is my code once again, and what you are saying is to Change "Worksheets("ActiveSheet.Name")" to Me.Worksheet("WorksheetName")? I am very sorry that I am slow, but thanks for your patience.
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Worksheets("ActiveSheet.Name").ChartObjects(1).Chart.Axes(xlValue)
.MinimumScale = Worksheets("ActiveSheet.Name").Range("M11").Value
.MaximumScale = Worksheets("ActiveSheet.Name").Range("N11").Value
End With
End Sub