Your setup is not really condusive to your requirement...
See result sheet...Headings are in order of census sheet...so perhaps change accordingly...
Sub J3v16()
Dim Data, Temp, Arr, Crit As String, i As Long, ii As Long, x As Long
Arr = [{8,9,10,11,12,13,14,15,20,21,22,23,24,25,26,27,28,29}]
Data = Sheets("census").ListObjects(1).Range
ReDim Temp(1 To UBound(Data), 1 To 18)
For i = 2 To UBound(Data)
If Data(i, 3) <> "" Then
Crit = Data(i, 3) & " Bed " & Data(i, 1)
x = x + 1
For ii = 1 To UBound(Arr)
If Data(i, Arr(ii)) <> "" Then
Temp(x, ii) = IIf(IsDate(Data(i, Arr(ii))), Crit & " " & Data(i, Arr(ii)), Crit)
End If
Next ii
End If
Next i
With Sheets("Result") '! For testing purposes...
.Rows(2 & ":" & .Rows.Count).Delete
.Cells(2, 1).Resize(x, 18) = Temp
.UsedRange.Columns.AutoFit
End With
With Sheets("Charge Report") '! Change headings accordingly...
.Rows(4 & ":" & .Rows.Count).Delete
.Cells(4, 2).Resize(x, 18) = Temp
.UsedRange.Columns.AutoFit
End With
End Sub
Bookmarks