#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default please help

Hi,

i have a requirement. i have five buttons on a sheet, and when user
clicks on a button, a form with a listbox will be displayed. the
listbox will be poppulated with the data based on which button user has
selected. i mean, each button click event will generate a unique array,
and all the member of array will be added to the listbox in the form. i
can create five different form to do that. but i want to know that, can
i use the same form to perform this operation for all five buttons?

Thanks,

King.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default please help

Certainly you can.

create your userform, name it frmTest
add to it a listbox, name is lstData

create a private sub routine named, PopulateData

private sub PopulateData
dim iLoop as integer

for iLoop = 1 to 100
'If you choose option A
lstData.additem "Option " & CurrentOption & " Item " & iLoop
'If you choose option B
lstData.additem "Option " & m_CurrentOption & " Item " & iLoop
next iLoop

end sub

now then, option A

add a module, name is basMain
in the module create a public variable CurrentOption
-- Option Explicit
-- public CurrentOption as Integer

Option B

in the userform code module create a public routine sub, named Init
and a private variable, m_CurrentOption
--Public Sub Init(buttonoption as integer)
-- m_CurrentOption = buttonoption
--End Sub

Finally on Button Click of each of your buttons

OpenForm <ButtonOption

private sub OpenForm(ButtonOption as integer)
dim f as frmTest
set f = new frmTest

if option a then CurrentOption = ButtonOption
if option b then f.init ButtonOption
f.show vbmodal
end sub



"King" wrote in message
oups.com...
Hi,

i have a requirement. i have five buttons on a sheet, and when user
clicks on a button, a form with a listbox will be displayed. the
listbox will be poppulated with the data based on which button user has
selected. i mean, each button click event will generate a unique array,
and all the member of array will be added to the listbox in the form. i
can create five different form to do that. but i want to know that, can
i use the same form to perform this operation for all five buttons?

Thanks,

King.



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



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