Sub UpdateLogWorksheet()
Dim historyWks As Worksheet
Dim inputWks As Worksheet
Dim nextRow As Long
Dim oCol As Long
Dim myRng As Range
Dim myCopy As String
Dim myCell As Range
Dim myCopy2 As String
Dim myRng2 As Range
Dim off As Long
myCopy = "D5,D7,D9,D11,D13,D15,D17,D19,D21,D23,D25,D27,D29,D31,D33,D35,D37,D39,D41,D43,D45,D47,D49,D51,D53,D55,D57,D59"
myCopy2 = "D23,D25,D27,D29,D31,D33"
Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("Total")
With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With
With inputWks
Set myRng = .Range(myCopy)
Set myRng2 = .Range(myCopy2)
If Application.CountA(myRng) <> myRng.Cells.Count Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With
With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "dd/mm/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
Do
off = off + 2
Set myRng2 = myRng2.Offset(, off)
If WorksheetFunction.CountA(myRng2) < 1 Then Exit Do
nextRow = nextRow + 1
With .Cells(nextRow, 1).Resize(, 11)
.Value = .Offset(-1).Value
End With
oCol = 12
For Each myCell In myRng2.Cells
.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
myRng2.clearcontents
Loop
End With
myRng.clearcontents
Application.GoTo inputWks.Cells(1)
End Sub