Hey Folks,
Someone decided on a terrible way to record attendances which I would like to remedy.
As you can, hopefully, see below, I would like to translate this into a proper spreadsheet format with column A for Name and column E for Date attended.
I have some simple code which should loop through each column and row to achieve this. The code works as expected until it gets to "B5" and instead of if statement seeing the "X" and carrying out the code, it skips over as if it doesn't fit the criteria. This happens at random spots throughout and therefore misses a number of attendances.
I can't figure it out!! Any help would be greatly appreciated.
Someone decided on a terrible way to record attendances which I would like to remedy.
As you can, hopefully, see below, I would like to translate this into a proper spreadsheet format with column A for Name and column E for Date attended.
I have some simple code which should loop through each column and row to achieve this. The code works as expected until it gets to "B5" and instead of if statement seeing the "X" and carrying out the code, it skips over as if it doesn't fit the criteria. This happens at random spots throughout and therefore misses a number of attendances.
I can't figure it out!! Any help would be greatly appreciated.
VBA Code:
Sub Transpose()
Dim wb As ThisWorkbook
Dim LastCol As Long
Dim LastRow As Long
Dim NxtRow As Long
Dim i As Integer
Dim j As Integer
LastCol = RawData.Range("A1").CurrentRegion.Columns.Count
LastRow = RawData.Cells(RawData.Rows.Count, "A").End(xlUp).Row
NxtRow = Attendances.Cells(RawData.Rows.Count, "A").End(xlUp).Row + 1
For i = 1 To LastCol
For j = 2 To LastRow
If RawData.Cells(i, j).Value = "X" Then
Attendances.Range("E" & NxtRow).Value = RawData.Cells(1, i)
Attendances.Range("A" & NxtRow).Value = RawData.Cells(j, 1)
NxtRow = NxtRow + 1
End If
Next j
Next i
End Sub