Hi there,
I have a small problem with my array dateSlot is not storing any values and I no idea why is that so. Its causing values to always be 0 in the array. Can anyone help me on this?
Any help will be greatly appreciated. Thanks in advance! 
Option Compare Text
Sub dataSorter()
Dim i As Double
Dim x As Double
Dim k As Double
Dim r1 As Range
Dim daterowNum As Double
Dim dateCount As Double
Dim dateSlot() As Double
Dim rowCount As Double
Dim maxRow As Double
Dim maxRowColumn As Double
Dim arr() As Long
Set r1 = Sheet1.Range("A:A")
For i = 1 To 10
For x = 1 To 10
If r1.Cells(i, x).Value Like "*date*" Then
daterowNum = i
Exit For
End If
Next x
Next i
For i = 1 To 256
If r1.Cells(daterowNum, i).Value Like "*date*" Then
dateCount = dateCount + 1
ReDim dateSlot(dateCount)
'MsgBox dateSlot(dateCount)
For x = 1 To dateCount
If dateSlot(x) <> 0 Then
dateSlot(x) = i
MsgBox dateSlot(x)
Exit For
End If
Next x
r1.Cells(daterowNum + 1, i).Select
Range(Selection, Selection.End(xlDown)).Select
If maxRow < Selection.Rows.Count Then
maxRow = Selection.Rows.Count
maxRowColumn = i
End If
End If
Next i
ReDim arr(maxRow, dateCount + 1)
For i = 1 To maxRow
arr(i, 1) = r1.Cells(i + daterowNum, maxRowColumn)
Next i
'MsgBox dateSlot(2)
For i = 1 To maxRow
For k = 1 To dateCount
For x = 1 To maxRow
If r1.Cells(x, dateSlot(k)).Value = arr(i, 1) Then
r1.Cells(x, dateSlot(k) + 1).Value = arr(i, k + 1)
Exit For
End If
Next x
Next k
Next i
End Sub
Bookmarks