Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Retrieve an array from a function?

Help please!

I am using VBA in Excel XP with Windows 2000.

I am fairly experienced using VBA, but I recently began
using functions. Is it possible to return an array from a
function?

For example, the following function call retrieves a month
and a year from drop downs in a toolbar. The actual
function gets the information, but how do I retrieve this
info from the function to my subroutine in a separate
module?

Call Obtain_Period("Bank_Month", "Bank_Year")

Thanks inadvance for the lesson. Your example code would
be most appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Retrieve an array from a function?

You don't need a function

Sub DoingTheCalling()
dim lngMonth as Long
Dim lngYear as Long
Call Obtain_Period(lngMonth, lngYear)
msgbox "Month: " & lngMonth & " Year: " & lngYear
End Sub

Sub Obtain_Period(lMonth as Long, lYear as Long)
Dim ctlMonthComboBox As CommandBarComboBox
Dim ctlYearComboBox As CommandBarComboBox
Dim cBar as Commandbar
set cBar = CommandBars("Custom1")
set ctlMonthCombobox = cbar.Controls("MonthDropDown")
set ctlYearCombobox = cbar.Controls("YearDropDown")
lMonth = clng(ctlMonthCombobox.Text)
lYear = clng(ctlYearCombobox.Text)
End Sub

If your Month combobox is producing strings, then change the code to address
a string.

--
Regards,
Tom Ogilvy



"PK" wrote in message
...
Help please!

I am using VBA in Excel XP with Windows 2000.

I am fairly experienced using VBA, but I recently began
using functions. Is it possible to return an array from a
function?

For example, the following function call retrieves a month
and a year from drop downs in a toolbar. The actual
function gets the information, but how do I retrieve this
info from the function to my subroutine in a separate
module?

Call Obtain_Period("Bank_Month", "Bank_Year")

Thanks inadvance for the lesson. Your example code would
be most appreciated.



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
function to retrieve array name Monty Excel Worksheet Functions 6 October 27th 09 04:58 AM
Is it possible to use the lookup function to retrieve objects? MAC Excel Discussion (Misc queries) 1 May 12th 09 03:15 AM
Is there a function/formula to retrieve the weeknumber? Marijke Excel Worksheet Functions 1 October 5th 07 11:36 AM
function to retrieve a list of unique characters from a column Pluggie Excel Worksheet Functions 2 June 13th 07 04:17 PM
Can I retrieve a value and its format using the minimum function? daled Excel Worksheet Functions 1 November 2nd 05 09:38 PM


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

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"