Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run-time error '13':Type mismatch


Hi all

I am trying to make a VBA code for a Graph, giving the opprtunity to
the user to change the X-axis and y-axis sources. the code change very
well the first axis but block at the 2ndf axis with *Run-time error
'13':Type mismatch * ;

Here is my code:


Sub Axis_Graph()
Dim startYear As Integer
Dim EndYear As Integer
Dim startYear2 As Integer
Dim EndYear2 As Integer
Dim StartLine As Integer
Dim EndLine As Integer

startYear = 1950 ' default value
EndYear = 2050 ' default value
startYear2 = Sheets("Incidence").Range("H9").Value ' choose by the
user
EndYear2 = Sheets("Incidence").Range("J9").Value ' choose by the user

StartLine = 3 + (startYear2 - startYear) 'Calculte the row number
where is the StartYear2

EndLine = 103 - (EndYear2 - EndYear) 'Calculte the row number where
is
the EndYear2

With Sheets("Incidence")
ChartObjects("Chart 32").Chart.SeriesCollection(1).XValues = _
Range(.Cells(StartLine, "W"), .Cells(EndLine, "W"))

CHARTOBJECTS(\"CHART 32\").CHART.SERIESCOLLECTION(1).VALUES = _
RANGE(.CELLS(STARTLINE, \"X\"), .CELLS(ENDLINE, \"X\"))
END WITH

end sub

Thanks

Sibilia


--
Sibilia
------------------------------------------------------------------------
Sibilia's Profile: http://www.excelforum.com/member.php...o&userid=21363
View this thread: http://www.excelforum.com/showthread...hreadid=384181

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Run-time error '13':Type mismatch

Sub Axis_Graph()
Dim startYear As Integer
Dim EndYear As Integer
Dim startYear2 As Integer
Dim EndYear2 As Integer
Dim StartLine As Integer
Dim EndLine As Integer
Dim rngX As Range
Dim rngY As Range

startYear = 1950 ' default value
EndYear = 2050 ' default value
startYear2 = Sheets("Incidence").Range("H9").Value ' choose by the

EndYear2 = Sheets("Incidence").Range("J9").Value ' choose by the user

StartLine = 3 + (startYear2 - startYear)
EndLine = 103 + (EndYear2 - EndYear)

Debug.Print StartLine, EndLine
With Sheets("Incidence")
Set rngX = .Range(.Cells(StartLine, "W"), _
.Cells(EndLine, "W"))

Set rngY = .Range(.Cells(StartLine, "X"), _
.Cells(EndLine, "X"))

.ChartObjects("Chart 32").Chart.SeriesCollection(1) _
.XValues = "=" & rngX.Address(True, True, xlR1C1, True)

.ChartObjects("Chart 32").Chart.SeriesCollection(1) _
.Values = "=" & rngY.Address(True, True, xlR1C1, True)

End With

End Sub

works for me.

--
Regards,
Tom Ogilvy

"Sibilia" wrote in
message ...

Hi all

I am trying to make a VBA code for a Graph, giving the opprtunity to
the user to change the X-axis and y-axis sources. the code change very
well the first axis but block at the 2ndf axis with *Run-time error
'13':Type mismatch * ;

Here is my code:


Sub Axis_Graph()
Dim startYear As Integer
Dim EndYear As Integer
Dim startYear2 As Integer
Dim EndYear2 As Integer
Dim StartLine As Integer
Dim EndLine As Integer

startYear = 1950 ' default value
EndYear = 2050 ' default value
startYear2 = Sheets("Incidence").Range("H9").Value ' choose by the
user
EndYear2 = Sheets("Incidence").Range("J9").Value ' choose by the user

StartLine = 3 + (startYear2 - startYear) 'Calculte the row number
where is the StartYear2

EndLine = 103 - (EndYear2 - EndYear) 'Calculte the row number where
is
the EndYear2

With Sheets("Incidence")
ChartObjects("Chart 32").Chart.SeriesCollection(1).XValues = _
Range(.Cells(StartLine, "W"), .Cells(EndLine, "W"))

CHARTOBJECTS(\"CHART 32\").CHART.SERIESCOLLECTION(1).VALUES = _
RANGE(.CELLS(STARTLINE, \"X\"), .CELLS(ENDLINE, \"X\"))
END WITH

end sub

Thanks

Sibilia


--
Sibilia
------------------------------------------------------------------------
Sibilia's Profile:

http://www.excelforum.com/member.php...o&userid=21363
View this thread: http://www.excelforum.com/showthread...hreadid=384181



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run-time error '13':Type mismatch


Many thanks Tom!

It works ! I am going to try to understand more this style of
programming.... mine is too simple and do not work each time!

Many Many thanks!

Sibilia




Tom Ogilvy Wrote:
Sub Axis_Graph()
Dim startYear As Integer
Dim EndYear As Integer
Dim startYear2 As Integer
Dim EndYear2 As Integer
Dim StartLine As Integer
Dim EndLine As Integer
Dim rngX As Range
Dim rngY As Range

startYear = 1950 ' default value
EndYear = 2050 ' default value
startYear2 = Sheets("Incidence").Range("H9").Value ' choose by the

EndYear2 = Sheets("Incidence").Range("J9").Value ' choose by the user

StartLine = 3 + (startYear2 - startYear)
EndLine = 103 + (EndYear2 - EndYear)

Debug.Print StartLine, EndLine
With Sheets("Incidence")
Set rngX = .Range(.Cells(StartLine, "W"), _
.Cells(EndLine, "W"))

Set rngY = .Range(.Cells(StartLine, "X"), _
.Cells(EndLine, "X"))

.ChartObjects("Chart 32").Chart.SeriesCollection(1) _
.XValues = "=" & rngX.Address(True, True, xlR1C1, True)

.ChartObjects("Chart 32").Chart.SeriesCollection(1) _
.Values = "=" & rngY.Address(True, True, xlR1C1, True)

End With

End Sub

works for me.

--
Regards,
Tom Ogilvy

"Sibilia" wrote
in
message ...

Hi all

I am trying to make a VBA code for a Graph, giving the opprtunity to
the user to change the X-axis and y-axis sources. the code change

very
well the first axis but block at the 2ndf axis with *Run-time error
'13':Type mismatch * ;

Here is my code:


Sub Axis_Graph()
Dim startYear As Integer
Dim EndYear As Integer
Dim startYear2 As Integer
Dim EndYear2 As Integer
Dim StartLine As Integer
Dim EndLine As Integer

startYear = 1950 ' default value
EndYear = 2050 ' default value
startYear2 = Sheets("Incidence").Range("H9").Value ' choose by the
user
EndYear2 = Sheets("Incidence").Range("J9").Value ' choose by the

user

StartLine = 3 + (startYear2 - startYear) 'Calculte the row number
where is the StartYear2

EndLine = 103 - (EndYear2 - EndYear) 'Calculte the row number where
is
the EndYear2

With Sheets("Incidence")
ChartObjects("Chart 32").Chart.SeriesCollection(1).XValues = _
Range(.Cells(StartLine, "W"), .Cells(EndLine, "W"))

CHARTOBJECTS(\"CHART 32\").CHART.SERIESCOLLECTION(1).VALUES = _
RANGE(.CELLS(STARTLINE, \"X\"), .CELLS(ENDLINE, \"X\"))
END WITH

end sub

Thanks

Sibilia


--
Sibilia

------------------------------------------------------------------------
Sibilia's Profile:

http://www.excelforum.com/member.php...o&userid=21363
View this thread:

http://www.excelforum.com/showthread...hreadid=384181



--
Sibilia
------------------------------------------------------------------------
Sibilia's Profile: http://www.excelforum.com/member.php...o&userid=21363
View this thread: http://www.excelforum.com/showthread...hreadid=384181

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
run time error 13 type mismatch Rob Bovey Excel Programming 3 April 13th 10 12:09 PM
run-time error 13: Type mismatch? Marko Enula Excel Discussion (Misc queries) 2 February 5th 08 01:00 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM
run time error 13 type mismatch kkknie[_170_] Excel Programming 0 July 20th 04 03:28 PM
Run Time Error '13' Type mismatch David Adamson[_3_] Excel Programming 2 June 10th 04 04:00 AM


All times are GMT +1. The time now is 02:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"