ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passing a value and getting results (https://www.excelbanter.com/excel-programming/283157-passing-value-getting-results.html)

George[_16_]

Passing a value and getting results
 
I need to pass a value from a list box to a worksheet and
get a number of values back to display to a user. I'm
using a listbox for the user to choose the original value.
Does anyone have VB code to help me get started?

Tom Ogilvy

Passing a value and getting results
 
Private Sub Combobox1_Click()
with combobox1.listIndex
case 0
returnNumbers = Array(1,2,3)
case 1
returnNumbers = array(4,5,6)
case else
returnNumbers = array(7,8,9)
End Case
End Sub

In a general module

Public returnNumbers as Variant

Public Sub MyFunc()
Application.Volatile
MyFunc = returnNumbers
End Function

Select A1 to C1
in the formulabar enter
=MyFunc()

end with Ctrl+Shift+Enter




--
Regards,
Tom Ogilvy



"George" wrote in message
...
I need to pass a value from a list box to a worksheet and
get a number of values back to display to a user. I'm
using a listbox for the user to choose the original value.
Does anyone have VB code to help me get started?





All times are GMT +1. The time now is 10:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com