Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default error 13 when setting worksheet listbox

Sorry for the multipost but my message didn't appear in the other
group and microsoft.public.excel.programming is more appropriate
anyway.


A code snippet:

Function FillYearMonth(ByVal theWorkSheet As String, ByVal
thePivotTable As String, ByVal thePageField As String)
Dim ws As Worksheet
Set ws = Worksheets(theWorkSheet)
Dim pt As PivotTable
Set pt = ws.PivotTables(thePivotTable)
Dim pf As PivotField
Set pf = pt.PivotFields(thePageField)
Dim lb As ListBox
Set lb = Worksheets(theWorkSheet).lstYearMonth
Call FillListBox(pf, lb)
End Function

I keep getting error 13 after executing the line
Set lb = Worksheets(theWorkSheet).lstYearMonth

I checked and there really is a ListBox called lstYearMonth on the
worksheet (on ever worksheet there is a ListBox named lstYearMonth)


Can anyone point me what is wrong in this code?


--
Amedee
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default error 13 when setting worksheet listbox

While lstYearMonth may be an embedded object in the sheet you can not
directly reference it as you have since your code does not make the
connection until run time. To directly reference the object you would need to
have the actual sheet where you have the object so that the connection is
there at design time... Try this

set lb = Worksheets(theWorkSheet).oleobject("lstYearMonth")

Also declare your variables with lb as type OLEObject
--
HTH...

Jim Thomlinson


"Amedee Van Gasse" wrote:

Sorry for the multipost but my message didn't appear in the other
group and microsoft.public.excel.programming is more appropriate
anyway.


A code snippet:

Function FillYearMonth(ByVal theWorkSheet As String, ByVal
thePivotTable As String, ByVal thePageField As String)
Dim ws As Worksheet
Set ws = Worksheets(theWorkSheet)
Dim pt As PivotTable
Set pt = ws.PivotTables(thePivotTable)
Dim pf As PivotField
Set pf = pt.PivotFields(thePageField)
Dim lb As ListBox
Set lb = Worksheets(theWorkSheet).lstYearMonth
Call FillListBox(pf, lb)
End Function

I keep getting error 13 after executing the line
Set lb = Worksheets(theWorkSheet).lstYearMonth

I checked and there really is a ListBox called lstYearMonth on the
worksheet (on ever worksheet there is a ListBox named lstYearMonth)


Can anyone point me what is wrong in this code?


--
Amedee

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
Worksheet setting error... Lakshmi Murthy Excel Worksheet Functions 0 September 23rd 09 03:03 PM
error 13 when setting worksheet listbox Amedee Van Gasse Excel Discussion (Misc queries) 1 September 24th 08 02:06 PM
Setting a Control Variable for a listbox jonefer Excel Programming 2 February 6th 08 05:11 AM
Setting Listbox Size VBA Sandy Excel Worksheet Functions 1 April 27th 07 05:48 PM
Setting and filter Listbox data Gizmo63 Excel Discussion (Misc queries) 1 February 5th 07 04:03 PM


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