PDA

View Full Version : Unable to read formula cells value



hepzibahr
10-19-2011, 10:14 AM
Private Sub Worksheet_Activate()
Dim maxvalue As Integer
Dim minvalue As Integer
minValue = Sheets("Table 1").Range("A12").Value
minValue = Sheets("Table 1").Range("A13").Value
Sheets("F1 Projekt").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.HasAxis(xlValue) = True
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.Axes(xlValue).Select
ActiveChart.Axes(xlValue).MinimumScale = minValue
ActiveChart.Axes(xlValue).MaximumScale =maxValue
'ActiveChart.Axes(xlValue).MajorUnit = 300000
ActiveChart.Axes(xlValue).MinorUnit = 400000
ActiveChart.Refresh
End Sub



Iam getting error in the line where i get the minValue ,maxvalue .
A12 in Sheet Table 1 holds a fomula MIN(C5:D10) same goes for A13 which has max(c5:D10)

Merton
10-19-2011, 12:12 PM
What does the error say?
Are you sure the values are Integers?

Merton
10-19-2011, 12:13 PM
you did not capitalize the "V"s in the DIM lines.

mdmackillop
10-19-2011, 01:36 PM
Welcome to VBAX

Too many MinValues

minValue = Sheets("Table 1").Range("A12").Value
minValue = Sheets("Table 1").Range("A13").Value

also, Max value of Integer data type is 32,767; use Long instead.

hepzibahr
10-20-2011, 02:40 AM
changing to Long worked for me .

hepzibahr
10-20-2011, 02:41 AM
thanks for the help