Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default object pointers


I'm new to VBA. I'm trying to make an object pointer so I can
dynamically populate some ComboBoxes. Here is what doesn't work:


Code:
--------------------
Public Sub showForm()
UserForm1.Show
Sheet1.Activate

For i = 1 To 4
a = "UserForm1.ComboBox" & i
a.ColumnCount = 1
a.RowSource = "A2:A11"
Next i

End Sub
--------------------


I've tryed switching data types with "as object" with no luck.
Searching for this on the web is crazy. It seems everyone wants some
pointers on using excel. :)


--
rando4
------------------------------------------------------------------------
rando4's Profile: http://www.excelforum.com/member.php...o&userid=28315
View this thread: http://www.excelforum.com/showthread...hreadid=478994

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default object pointers

Public Sub showForm()
Dim a as Object
For i = 1 To 4
set a = Userform1.Controls("Combobox" & i)
a.ColumnCount = 1
a.RowSource = "Sheet1!A2:A11"
Next i
UserForm1.Show
End Sub
--------------------

--
Regards,
Tom Ogilvy

"rando4" wrote in
message ...

I'm new to VBA. I'm trying to make an object pointer so I can
dynamically populate some ComboBoxes. Here is what doesn't work:


Code:
--------------------
Public Sub showForm()
UserForm1.Show
Sheet1.Activate

For i = 1 To 4
a = "UserForm1.ComboBox" & i
a.ColumnCount = 1
a.RowSource = "A2:A11"
Next i

End Sub
--------------------


I've tryed switching data types with "as object" with no luck.
Searching for this on the web is crazy. It seems everyone wants some
pointers on using excel. :)


--
rando4
------------------------------------------------------------------------
rando4's Profile:

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default object pointers


Hello Rando4,

Neither Visual Basic nor Visual Basic for Applications use objec
pointers in the traditional sense of a pointer. I have made the change
to the code to do what you want.

By the way, do you want all for ComboBoxes to be filled with the sam
range data?



Code
-------------------
Public Sub showForm()
Dim CB as Object

UserForm1.Show
Sheet1.Activate

For i = 1 To 4
Set CB = UserForm1.Controls("ComboBox" & i)
With CB
.ColumnCount = 1
.RowSource = "Sheet1!$A$2:$A$11"
End With
Next i

End Sub

-------------------


Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=47899

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
Mouse Pointers Charles S Excel Discussion (Misc queries) 2 July 11th 07 09:50 PM
need some pointers golem New Users to Excel 2 April 27th 07 11:05 PM
Pointers?? OzziJC Excel Programming 8 June 24th 05 08:34 AM
Pointers?? OzziJC Excel Discussion (Misc queries) 2 June 22nd 05 04:12 PM
Pointers to appropriate functions Chris Excel Programming 2 October 25th 04 11:56 PM


All times are GMT +1. The time now is 01:27 AM.

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

About Us

"It's about Microsoft Excel"