Yes, I'm deleting all the rows after the last row with valid data on it. After hitting CTRL-END, Excel takes me to the very last row. The column it takes me to is correct, but the row is VERY far from where it should be.
The data is being entered manually. There is, however, a short VBA script I can use to enter in data without having to do fully manual entry. My workbook is a basic attendance log. Sheets are by month, columns are the dates of the month, rows are the employees.
Private Sub CommandButton1_Click()
Dim ws As Worksheet
Dim i As Integer
Dim j As Integer
Dim dateSearch As String
Set ws = Worksheets(Me.dateMonthYear.Value) //sets the ws to the month selected
// sets the date
If dateMonthYear.Value = "Jan-17" Then
dateSearch = "1/" & Me.dateDay.Value & "/2017"
ElseIf dateMonthYear.Value = "Feb-17" Then
dateSearch = "2/" & Me.dateDay.Value & "/2017"
ElseIf dateMonthYear.Value = "Mar-17" Then
dateSearch = "3/" & Me.dateDay.Value & "/2017"
ElseIf dateMonthYear.Value = "Apr-17" Then
dateSearch = "4/" & Me.dateDay.Value & "/2017"
ElseIf dateMonthYear.Value = "May-17" Then
dateSearch = "5/" & Me.dateDay.Value & "/2017"
ElseIf dateMonthYear.Value = "Jun-17" Then
dateSearch = "6/" & Me.dateDay.Value & "/2017"
ElseIf dateMonthYear.Value = "Jul-17" Then
dateSearch = "7/" & Me.dateDay.Value & "/2017"
ElseIf dateMonthYear.Value = "Aug-17" Then
dateSearch = "8/" & Me.dateDay.Value & "/2017"
ElseIf dateMonthYear.Value = "Sep-17" Then
dateSearch = "9/" & Me.dateDay.Value & "/2017"
ElseIf dateMonthYear.Value = "Oct-17" Then
dateSearch = "10/" & Me.dateDay.Value & "/2017"
ElseIf dateMonthYear.Value = "Nov-17" Then
dateSearch = "11/" & Me.dateDay.Value & "/2017"
ElseIf dateMonthYear.Value = "Dec-17" Then
dateSearch = "12/" & Me.dateDay.Value & "/2017"
End If
For i = 3 To 83
If Me.sName.Value = ws.Cells(i, 1).Value Then
//Logs the data entered on the form into the ws
For j = 3 To 64
If dateSearch = ws.Cells(1, j).Value Then
ws.Cells(i, j + 1).Value = Me.hrsIn.Value
ws.Cells(i + 1, j).Value = Me.abCode.Value
ws.Cells(i + 1, j + 1).Value = Me.hrsOut.Value
ws.Cells(i + 2, j).Value = Me.atComments.Value
//Adds color code to cells depending on the code
If Me.abCode.Value = "V" Or Me.abCode.Value = "PH" Or Me.abCode.Value = "HC" Or Me.abCode.Value = "PLP" Or Me.abCode.Value = "PDD" Or Me.abCode.Value = "AL" Then
ws.Cells(i, j + 1).Interior.Color = RGB(204, 192, 218)
ws.Cells(i + 1, j).Interior.Color = RGB(204, 192, 218)
ws.Cells(i + 1, j + 1).Interior.Color = RGB(204, 192, 218)
ws.Cells(i + 2, j).Interior.Color = RGB(204, 192, 218)
ElseIf Me.abCode.Value = "BL" Or Me.abCode.Value = "FS" Or Me.abCode.Value = "S" Then
ws.Cells(i, j + 1).Interior.Color = RGB(216, 228, 188)
ws.Cells(i + 1, j).Interior.Color = RGB(216, 228, 188)
ws.Cells(i + 1, j + 1).Interior.Color = RGB(216, 228, 188)
ws.Cells(i + 2, j).Interior.Color = RGB(216, 228, 188)
ElseIf Me.abCode.Value = "CTO" Or Me.abCode.Value = "FH" Or Me.abCode.Value = "ITO" Or Me.abCode.Value = "JD" Or Me.abCode.Value = "OSB" Then
ws.Cells(i, j + 1).Interior.Color = RGB(255, 255, 153)
ws.Cells(i + 1, j).Interior.Color = RGB(255, 255, 153)
ws.Cells(i + 1, j + 1).Interior.Color = RGB(255, 255, 153)
ws.Cells(i + 2, j).Interior.Color = RGB(255, 255, 153)
Else
ws.Cells(i, j + 1).Interior.ColorIndex = 0
ws.Cells(i + 1, j).Interior.ColorIndex = 0
ws.Cells(i + 1, j + 1).Interior.ColorIndex = 0
ws.Cells(i + 2, j).Interior.ColorIndex = 0
End If
Exit For
End If
Next j
Exit For
End If
Next i
//clears the form
Me.sName.Value = ""
Me.hrsIn.Value = ""
Me.hrsOut.Value = ""
Me.abCode.Value = ""
Me.atComments.Value = ""
//focuses on the first field.
Me.sName.SetFocus
End Sub