Results 1 to 2 of 2

Thread: [Excel VBA] Getting values for VBA array from spreadsheet range

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    May 2011
    Posts
    42

    [Excel VBA] Getting values for VBA array from spreadsheet range

    Hi, I have some code I am looking at, and it currently assigns values to a VBA array as a block from a range in the spreadsheet by doing:

    Code:
    Dim DataArray As Variant
    Workbooks("whatever.xlsm").Activate
    Sheets("Sheet1").Select
    DataArray = Range("A2:EV1000").Value
    I want to do this same thing without selecting. I tried

    Code:
    DataArray = Workbooks("whatever.xlsm").Sheets("Sheet1").Range("A2:EV1000").Value
    but that gave an error. What should I do? Thanks for any help!

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
    UPDATE: Apparently, the code above does work. But, the code I actually used was Windows("whatever.xlsm")... I had never seen Windows used before but it was in code I was updating a bit. So, my new question is:

    What's the different between Windows and Workbooks? Are they mostly the same? Why does Windows not work above, but Workbooks does?

    Thanks
    Last edited by ActSciMan; Jul 12th, 2011 at 03:01 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width