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.
Bookmarks