'Populating range from array
I have a worksheet change event that runs when three adjacent cells in columns C, D and E are filled with any value, which puts the date of entry into a separate worksheet as well as the name of the sheet where the data was captured from.
Then the code is supposed to count all instances of those dates for each day of the year.
If I step through the array FrstLetter is outputting the correct value.
Where I'm struggling: it then outputs said value back via application.transpose(myarray)
as no value is input when it loops through.
With Sheets("Log")
For RowCount = 1 To 60
Select Case RowCount
Case 2, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57
LastRow = .Range("A" & .Rows.Count).End(xlUp).Row
DateRange = WorksheetFunction.CountA(.Range("F" & RowCount & ":AJ" & RowCount))
For TypCount = 1 To 3
SheetIdent = .Cells(RowCount + TypCount, 5).Value
For ClmnNmbr = 1 To DateRange
ReDim AddrArr(DateRange)
AddrArr(ClmnNmbr) = .Cells(RowCount, ClmnNmbr + 5).Value
Set arrDates = .Range("A60:A" & LastRow)
Set shtNames = .Range("B60:B" & LastRow)
ReDim FrstLetter(DateRange)
FrstLetter(ClmnNmbr) = Application.CountIfs(arrDates, AddrArr(ClmnNmbr), shtNames, SheetIdent)
Worksheets("Log").Cells(TypCount + RowCount, ClmnNmbr + 5).Value = Application.Transpose(FrstLetter)
Next ClmnNmbr
Next TypCount
Case Else
End Select
Next RowCount
End With
I have a feeling I'm messing up somewhere with the transpose because everything else seems to work.
Solution 1:[1]
I figured it out, don't try to empty your entire array into one cell is the answer! Application.Transpose(FrstLetter(ClmnNmbr))
adding ClmnNmbr
made sure, as it was looping, only one value was output per cell since the cells were also being looped through.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Drawleeh |