You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
I have some data in a colum that can vary in the amount of rows. I would like to assign this data to an array. I would then like to populate some columns in my worksheet the data in the array.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rngUsedColACells As Range
Dim strAryColACellVals() As String
Dim intLoopCounter As Integer
Set rngUsedColACells = Range("A1:A" & Worksheets(1).UsedRange.Rows.Count)
intLoopCounter = 0
For Each cell In rngUsedColACells
ReDim Preserve strAryColACellVals(intLoopCounter)
strAryColACellVals(intLoopCounter) = cell.Value
intLoopCounter = intLoopCounter + 1
Next cell
End Sub