Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Access control on a worksheet - help!

Hi,
can anybody help me? I am trying to access a listbox control on a
worksheet and populate it with an array. For example:

Sub MySub()
Dim mySheet As Worksheet
Dim tempArray As Variant

' populate the tempArray ........

Set mySheet = Sheets("Test sheet")
mySheet.ListBox1.List() = tempArray 'A variant array
End Sub

The error message is: Compile error, method or data member not found

However this works just fine: Sheets("Test sheet").ListBox1.List() =
tempArray

I would like to use the variable mySheet instead (better programming
practice I assume!)

Any ideas? Thanks in advance to all :-)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Access control on a worksheet - help!

MonkeyMan

I don't know why that is, but this works:

mySheet.OLEObjects("ListBox1").List()=...

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"MonkeyMan" wrote in message
om...
Hi,
can anybody help me? I am trying to access a listbox control on a
worksheet and populate it with an array. For example:

Sub MySub()
Dim mySheet As Worksheet
Dim tempArray As Variant

' populate the tempArray ........

Set mySheet = Sheets("Test sheet")
mySheet.ListBox1.List() = tempArray 'A variant array
End Sub

The error message is: Compile error, method or data member not found

However this works just fine: Sheets("Test sheet").ListBox1.List() =
tempArray

I would like to use the variable mySheet instead (better programming
practice I assume!)

Any ideas? Thanks in advance to all :-)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default Access control on a worksheet - help!

Or change the sheet declaration to Object i.e.

Dim mySheet As Object

--

"Dick Kusleika" wrote in message ...
MonkeyMan

I don't know why that is, but this works:

mySheet.OLEObjects("ListBox1").List()=...

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"MonkeyMan" wrote in message
om...
Hi,
can anybody help me? I am trying to access a listbox control on a
worksheet and populate it with an array. For example:

Sub MySub()
Dim mySheet As Worksheet
Dim tempArray As Variant

' populate the tempArray ........

Set mySheet = Sheets("Test sheet")
mySheet.ListBox1.List() = tempArray 'A variant array
End Sub

The error message is: Compile error, method or data member not found

However this works just fine: Sheets("Test sheet").ListBox1.List() =
tempArray

I would like to use the variable mySheet instead (better programming
practice I assume!)

Any ideas? Thanks in advance to all :-)

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Access control on a worksheet - help!

ODW

Good one. That makes it a little clearer. Worksheet is a class that
represents all (each) worksheet. Since every worksheet isn't likely to have
a ListBox1, then the general Worksheet class won't have that data member.
But if you declared like

Dim mySheet as Sheet1

it would also work because you're declaring the variable as that specific
class. I'm surprised that Object resolves to the specific class, but that's
not entirely without merit. And in either case, TypeName(mysheet) is
Worksheet.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"onedaywhen" wrote in message
om...
Or change the sheet declaration to Object i.e.

Dim mySheet As Object

--

"Dick Kusleika" wrote in message

...
MonkeyMan

I don't know why that is, but this works:

mySheet.OLEObjects("ListBox1").List()=...

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"MonkeyMan" wrote in message
om...
Hi,
can anybody help me? I am trying to access a listbox control on a
worksheet and populate it with an array. For example:

Sub MySub()
Dim mySheet As Worksheet
Dim tempArray As Variant

' populate the tempArray ........

Set mySheet = Sheets("Test sheet")
mySheet.ListBox1.List() = tempArray 'A variant array
End Sub

The error message is: Compile error, method or data member not found

However this works just fine: Sheets("Test sheet").ListBox1.List() =
tempArray

I would like to use the variable mySheet instead (better programming
practice I assume!)

Any ideas? Thanks in advance to all :-)



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Access control on a worksheet - help!

Cheers Guys, great help!
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
Control Access Jay Excel Discussion (Misc queries) 3 October 29th 08 09:21 PM
Configuring Excel 2003 to control access to Trusted Publishers [email protected] Excel Discussion (Misc queries) 0 July 10th 06 09:04 AM
In EXCEL,How do you control the access to SHEET2, based on a value Vikranth Excel Worksheet Functions 0 March 16th 05 12:13 PM
Excel VBA To Control Access Jeff[_18_] Excel Programming 0 August 7th 03 02:35 AM
Accessing ActiveX Controls using VBA - can't use Control.Name to access. Rob Bovey Excel Programming 2 July 30th 03 09:11 AM


All times are GMT +1. The time now is 11:48 PM.

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"