LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Help - Type mismatch when running loop with strings from arrays

I did steal your original code and missed that problem--but you found it and
that's good!



Marie J-son wrote:

Thank you, Dave

once more you have helped me and I find , as always, one more function,
property or object I hasn't used before. Arrays has always been a weak point
for me. As you saw, I kind of thought that I shouldn't need to loop through
them if I used arrays...

Except for one correction in your code, it work out fine! Actually, the
error probably originated from my code in the beginning...:-)
ChartTitle has not chartobject as parent, but a chart. Therefore "With
testChartObject." should be "With testChartObject.Chart".

Complete code:

Option Explicit
Sub ChartObjectTitles()

Dim alt As Variant
Dim cht As Variant
Dim qlt As Variant

Dim aCtr As Long
Dim cCtr As Long
Dim qCtr As Long

Dim testChartObject As ChartObject

alt = Array("21", "31", "41")
cht = Array("ROI", "CF", "Q")
qlt = Array("SB", "SBA", "S")

For aCtr = LBound(alt) To UBound(alt)
For cCtr = LBound(cht) To UBound(cht)
For qCtr = LBound(qlt) To UBound(qlt)
Set testChartObject = Nothing
On Error Resume Next
Set testChartObject _
= Sheet1.ChartObjects("C_" & cht(cCtr) & "_" _
& qlt(qCtr) & "_" & alt(aCtr))
On Error GoTo 0

If testChartObject Is Nothing Then
'it's not there, what should be done???
Else
With testChartObject.Chart
.HasTitle = True
.ChartTitle.Characters.Text _
= Sheet1.Range("T_" & cht(cCtr) & "_" _
& qlt(qCtr) & "_" & alt(aCtr))
End With
End If
Next qCtr
Next cCtr
Next aCtr

End Sub

/Regards


--

Dave Peterson
 
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
Type Mismatch Error when running a SELECT SQL Andy Dorph Excel Programming 1 February 9th 05 06:12 PM
Arrays and Strings [email protected] Excel Programming 1 September 2nd 04 08:40 AM
Arrays and Strings [email protected] Excel Programming 2 September 2nd 04 02:53 AM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM
Type mismatch while running If statement Stel Excel Programming 4 December 18th 03 09:19 AM


All times are GMT +1. The time now is 06:33 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"