Results 1 to 6 of 6

Thread: Sample of Visual Basic macros for working with arrays in Excel

  1. #1
    Join Date
    Jul 2006
    Posts
    218

    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"

  2. #2
    Join Date
    May 2008
    Posts
    4,831

    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.

  3. #3
    Join Date
    Sep 2005
    Posts
    1,306

    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.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,139

    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.

  5. #5
    Join Date
    Jul 2006
    Posts
    339

    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

  6. #6
    Join Date
    Aug 2006
    Posts
    181

    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

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,719,143,632.63859 seconds with 17 queries