I have found out what causes this error but I cannot pinpoint where it is coming from in my code. I even tested this macro in a separate worksheet in excel and it worked but in this worksheet it is not working. Can anyone guess as to why or offer any workarounds? I put a comment on the line with the error. Assume data is put in correctly.
Private Sub CommandButton1_Click()
Dim startDate As Date, endDate As Date, reason As String, name As String
name = InputBox("Please enter the name of the SLG as appears in column 1 on the worksheet:")
startDate = InputBox("Please enter the start date in MM/DD/YYYY format:")
endDate = InputBox("Please enter the end date in MM/DD/YYYY format:")
reason = InputBox("Please short description for the absence:")
Dim rng1 As Range, columnNumberStart As Integer, rowNumber As Integer, columnNumberEnd As Integer, test1 As String, test2 As String
Worksheets("FY-15 Schedule").Activate
Set rng1 = ActiveSheet.UsedRange.Find(name)
rowNumber = rng1.Row
Set rng1 = ActiveSheet.UsedRange.Find(startDate)
columnNumberStart = rng1.Column 'Says Error is on this line
Set rng1 = ActiveSheet.UsedRange.Find(endDate)
columnNumberEnd = ActiveSheet.UsedRange.Find(endDate).Column
test1 = Cells(rowNumber, columnNumberStart).Address
test2 = Cells(rowNumber, columnNumberEnd).Address
Dim rng2 As Range
Set rng2 = Range(test1, test2)
rng2.Value = reason
End Sub
Dim startDate as Variant?.Findmethod has returnedNothingto the range object, so then you are essentially doingNothing.Column, which is an error. Google for help on "finding date values" in Excel. I don't remember how to do it off the top of my head...