If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > pass values from excel worksheet to VBA array

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-18-09, 08:07
raysadude raysadude is offline
Registered User
 
Join Date: Sep 2009
Location: edmond,ok
Posts: 4
pass values from excel worksheet to VBA array

hi guys,

i'm a newb here as well with excel and vba, i'm trying to do my homework which requires me to pass values from an array in excel worksheet to VBA and print it in a msg box

i've tried

dim arr as variant
arr = range("A1:A6").value
msgbox arr

but it didn't work.

the array is number(double) and the msgbox would be combination between string and number
ex:the numbers are 1,2,3,4,5,6

that's the first step of the homework the second is i have 2 list of array

year:1999 - 2002
profit:10,20,30,40

i have to find the max profit and get the year when it occurs

i'd really appreciate any help/suggestions, oh and i did try the search function but couldn't get any relevant result.

Ray
Reply With Quote
  #2 (permalink)  
Old 09-18-09, 08:58
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
Take of the .Value and you should have it.

Ax
Reply With Quote
  #3 (permalink)  
Old 09-18-09, 13:31
raysadude raysadude is offline
Registered User
 
Join Date: Sep 2009
Location: edmond,ok
Posts: 4
Quote:
Originally Posted by Ax238
Take of the .Value and you should have it.

Ax
i tried that and that didn't work.

here's the code

Sub testAr()
Dim arr As Variant
arr = Range("A1:A6")
MsgBox TypeName(arr)

End Sub

the result is Variant()

Reply With Quote
  #4 (permalink)  
Old 09-18-09, 16:15
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
Doesn't seem to be a problem with it. What are you expecting it to return?

Edit: I just noticed you said this is homework. Homework is not our work, it's yours. Let me teach you the first and most important thing you can know if you want to succeed in your educational endeavors:
Let me google that for you

Last edited by Ax238; 09-18-09 at 16:19.
Reply With Quote
  #5 (permalink)  
Old 09-18-09, 16:35
raysadude raysadude is offline
Registered User
 
Join Date: Sep 2009
Location: edmond,ok
Posts: 4
o well, i'm just trying to learn. but thanks anyway. i know it's not your work but a help would be appreciated
Reply With Quote
  #6 (permalink)  
Old 09-18-09, 17:06
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
I have helped you, but there's a sense of satisfaction figuring things out on your own and I don't want to rob you of that. The link I gave you should lead you directly to the correct answer.

Have fun!

Ax
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On