Go Back   TechArena Community > Software > Windows Software
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , , ,

Sponsored Links



Sample of Visual Basic macros for working with arrays in Excel

Windows Software


Reply
 
Thread Tools Search this Thread
  #1  
Old 12-03-2010
Silent~Kid's Avatar
Member
 
Join Date: Jul 2006
Posts: 214
Sample of Visual Basic macros for working with arrays in Excel

Hello friends,
I have done some basic coding in Visual Basic Application in Excel. I am working with the macros that are used in an arrays. I have tried a lot of coding for that but I am getting an error everytime. I think that I am going wrong somewhere, so thought to ask you guys for the help. Can someone over there can provide me the sample of Visual Basic macros for working with arrays in Excel.?? Any other information related to the topic would be grateful.!!
__________________
~*~Silent~Kid~*~
"To The World You May Be Just One Person, But To One Person You May Be The World"
Reply With Quote
  #2  
Old 12-03-2010
Macarenas's Avatar
Member
 
Join Date: May 2008
Posts: 4,810
Re: Sample of Visual Basic macros for working with arrays in Excel

I think that you should first know about the macros properly to understand the coding of it in VB. A macro can automate repetitive tasks. Two different methods are used for creating Excel macros :
  • Record a user sequence
  • Programming in VBA
In absolute mode, the cursor moves to a cell reference well defined. By cons, in relative registration is on the move. In relative performance can move the cursor over cells lacking.
Reply With Quote
  #3  
Old 12-03-2010
kattman's Avatar
Member
 
Join Date: Sep 2005
Posts: 1,239
Re: Sample of Visual Basic macros for working with arrays in Excel

Visual Basic for Applications (VBA) is a programming environment that supports and automates most desktop applications from Microsoft. Excel often refuses to execute the VBA program (it also called macros or macros). When opening a workbook containing the code. For filling an array and copying it into a spreadsheet, follow the steps :
  1. Open a new workbook.
  2. Press Alt + F11 to run the Visual Basic Editor.
  3. On the Insert menu, click Module.
  4. Then you will have to type an appropriate code in module sheet.
  5. On the File menu, click Close and Return to Microsoft Excel.
  6. Select Sheet1.
  7. On the Tools menu, select Macro and then click Macros.
  8. In the Macro dialog box, click Sheet_Fill_Array, and then click Run.
Reply With Quote
  #4  
Old 12-03-2010
chroma's Avatar
Member
 
Join Date: Apr 2008
Posts: 2,144
Re: Sample of Visual Basic macros for working with arrays in Excel

If you want to retrieve values from the spreadsheet and fill the array, follow the steps mentioned below :
  1. Open a new workbook and enter values in cells A1: A10 on Sheet1.
  2. Press Alt + F11 to run the Visual Basic Editor.
  3. On the Insert menu, click Module.
  4. Then type the code in the module sheet.
  5. On the File menu, click Close and Return to Microsoft Excel.
  6. Select Sheet1.
  7. On the Tools menu, select Macro and then click Macros.
  8. In the Macro dialog box, click From_sheet_make_array, and then click Run.
Reply With Quote
  #5  
Old 12-03-2010
Member
 
Join Date: Jul 2006
Posts: 283
Re: Sample of Visual Basic macros for working with arrays in Excel

I am providing the code that you have to insert into the example provided by the 'chroma',
Code:
Sub From_sheet_make_array ()
       Dim myarray As Variant
       myarray = Range ( "a1: a10"). Value

       'Looping structure to look at array.
       For i = 1 To UBound (myarray)
      	 MsgBox myarray (i, 1)
       Next
    End Sub
Reply With Quote
  #6  
Old 12-03-2010
Soumen's Avatar
Member
 
Join Date: Aug 2006
Posts: 148
Re: Sample of Visual Basic macros for working with arrays in Excel

For passing and receiving an array in excel, follow the steps given below :
  1. Open a new workbook.
  2. Press Alt + F11 to run the Visual Basic Editor.
  3. On the Insert menu, click Module.
  4. Type the following code in the module sheet :
    Code:
    Sub Pass_array ()
           Dim myarray As Variant
           myarray = Range ( "a1: a10"). Value
           receive_array myarray
        End Sub
    
        Sub receive_array (thisarray)
           For i = 1 To UBound (myarray)
          	 MsgBox myarray (i, 1)
           Next
        End Sub
  5. On the File menu, click Close and Return to Microsoft Excel.
  6. Select Sheet1 and highlight the range A1: A10.
  7. On the Tools menu, select Macro and then click Macros.
  8. In the Macro dialog box, click Pass_array, and then click Run.
__________________
QTechnology Ultra-Quiet ATX PSU 460W I MSI K8N Neo4-F I AMD Opteron 144 CABNE0545 2.66Ghz I 2 x 512MB RAM I 380GB Maxtor SATAI Raid0 Hard Drive I 40GB Maxtor IDE Hard Drive I Nvidia GeForce 7900GTX I Win XP Home Service Pack 2 I Soundblaster Xtreme Fidelity Fatal1ty I Mercury Home Theater HT-4500
Reply With Quote
Reply

  TechArena Community > Software > Windows Software


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Sample of Visual Basic macros for working with arrays in Excel"
Thread Thread Starter Forum Replies Last Post
Looking for Excel Web Query for Java Applet working sample Omswaroop MS Office Support 3 2 Weeks Ago 08:12 PM
Excel not working properly to open macros Kungfu Pandey Windows Software 1 06-01-2012 10:03 PM
Arrays in Visual Basic 6.0 Palnila Software Development 3 26-12-2010 09:17 AM
Working with excel macros on a mac system Sheridan^OS Windows Software 5 13-12-2010 10:20 PM
How to use the Arrays in Visual Basic? The Recruiter Software Development 4 21-01-2010 08:13 PM


All times are GMT +5.5. The time now is 11:27 PM.