HI I have below code. I use to search for all rows from January and then copy to another sheet.
I have this kind of macro for all months.
I need to be able to change the year in the code from example 2013 and instead to 2014.
I have before dont this by making a reference to a cell and put this reference in the code.
In this case i cant make it work.
I want to make a refernce to example cell AW1 and then type in cell 2013. Then i can change the year in the cell.

I have tried this but it dont work.

Dim t as long
t = Sheets("Main"). Range("AW1")

and then put t into these lines

sdate = ("01-01-t ")
enddate = ("31-01-t ")
Please have a look and see how 2013 in the code can be changed to 2014 example.

Thanks in advance.

Abjac

Here is my code as it looks now.

Sub Searchcopyjan()
Dim sh As Worksheet
Dim LR As Long
Dim k As Long, j As Long
Dim myWord As String
Dim myRng As Range
Sheets("Main").Activate
Set sh = ThisWorkbook.Sheets("Jan")
    LR = sh.Cells(Rows.Count, "A").End(xlUp).Row
    Dim a As String
sdate = ("01-01-2013 ")
enddate = ("31-01-2013 ")
If sdate = "" Or enddate = "" Then Exit Sub
On Error Resume Next
Nsdate = CDate(sdate)
Nenddate = CDate(enddate)
On Error GoTo 0
drow = 2
For k = 4 To Cells(Rows.Count, "N").End(xlUp).Row
  fdate = Range("N" & k)
  If fdate >= Nsdate And fdate <= Nenddate Then

    sh.Rows(drow) = Rows(k).Value
    drow = drow + 1
    ffound = ffound + 1
  End If
Next k
If ffound = 0 Then
  MsgBox "Jan Not found, Try again"
  
  Exit Sub
End If
Call arrangejan
End Sub