Results 1 to 2 of 2

Access Dynamic Array from ThisWorkBook to Sheet1

Threaded View

  1. #1
    Registered User
    Join Date
    10-06-2012
    Location
    indonesia
    MS-Off Ver
    Excel 2012
    Posts
    2

    Access Dynamic Array from ThisWorkBook to Sheet1

    Dear All,
    I'm a new member here. Nice to meet you all.

    I have a trouble. I want to copy the column B to a dynamic array called ShipCode each I open the workbook, so I create Private Sub in "ThisWorkbook" like this.
    'In ThisWorkbook
    Dim ShipCode() As String
    Private Sub Workbook_Open()
        ReDim ShipCode(1 To Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row)
        For i = 1 To UBound(ShipCode)
            ShipCode(i) = Worksheets("Sheet1").Range("B" & i).Value
        Next i
    End Sub
    Then, I want to access the "ShipCode" array in Sheet1 Macro. For example, I'm trying to copy all element of ShipCode to column Q like this.
    'in Sheet1
    Sub try() 'i just want to try to access the ShipCode
        For i = 1 To Range("A" & Rows.Count).End(xlUp).Row
            Range("Q" & i) = ShipCode(i)
        Next i
    End Sub
    When I run "try" in Sheet1, the error comes. It said that: "Sub or Function not defined". So what I have to do? I want to access the "ShipCode" array in Sheet1 macros. Please, I need your help. Thanks before.
    Last edited by broro; 10-08-2012 at 01:35 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1