Simplere kode?
Denne kode må kunne skrives på en meget mere simpel måde?:If Cells(i, 4).Value >= #1/1/2008# And Cells(i, 4).Value <= #1/31/2008# Then
Cells(i, 8).Value = "Januar 2007"
End If
If Cells(i, 4).Value >= #2/1/2008# And Cells(i, 4).Value <= #2/29/2008# Then
Cells(i, 8).Value = "Februar 2007"
End If
If Cells(i, 4).Value >= #3/1/2008# And Cells(i, 4).Value <= #3/31/2008# Then
Cells(i, 8).Value = "March 2007"
End If
If Cells(i, 4).Value >= #4/1/2008# And Cells(i, 4).Value <= #4/30/2008# Then
Cells(i, 8).Value = "April 2007"
End If
If Cells(i, 4).Value >= #5/1/2008# And Cells(i, 4).Value <= #5/31/2008# Then
Cells(i, 8).Value = "May 2007"
End If
If Cells(i, 4).Value >= #6/1/2008# And Cells(i, 4).Value <= #6/30/2008# Then
Cells(i, 8).Value = "June 2007"
End If
If Cells(i, 4).Value >= #7/1/2008# And Cells(i, 4).Value <= #7/31/2008# Then
Cells(i, 8).Value = "July 2007"
End If
If Cells(i, 4).Value >= #8/1/2008# And Cells(i, 4).Value <= #8/31/2008# Then
Cells(i, 8).Value = "August 2007"
End If
If Cells(i, 4).Value >= #9/1/2008# And Cells(i, 4).Value <= #9/30/2008# Then
Cells(i, 8).Value = "September 2007"
End If
If Cells(i, 4).Value >= #10/1/2008# And Cells(i, 4).Value <= #10/31/2008# Then
Cells(i, 8).Value = "October 2007"
End If
If Cells(i, 4).Value >= #11/1/2008# And Cells(i, 4).Value <= #11/30/2008# Then
Cells(i, 8).Value = "November 2007"
End If
If Cells(i, 4).Value >= #12/1/2008# And Cells(i, 4).Value <= #12/31/2008# Then
Cells(i, 8).Value = "December 2007"
End If
Og hvis det samtidig kan lade sig gøre at VBA'en selv går ind afgør hvilket årstal det drejer sig om. Fx hvis jeg har en dato der sige 01-01-2009, så skriver den januar 2009 af sig selv??
