mardi 29 décembre 2015

VBA Conditional IF statement using WEEKDAY

I am trying to write a conditional IF statement based on the day of the week. column A has the date. Column AK has a weekend value, column AL has a weekday value. Need the correct value (depending on day of week) to flow into column AT. the code I came up with isn't working. All that's showing up in AT is the AK value. I'm pretty new to VBA, I'm definitely missing something. Thanks in advance for any help.

Sub Weekday()

For i = 2 To Cells(Rows.Count, "A").End(xlUp).Row

If Range("A" & i) = "=Weekday" Then 'This line of code doesn't work

Range("AT" & i).Value = Range("AL" & i).Value 'This line of code works

Else
Range("AT" & i).Value = Range("AK" & i).Value 'This line of code works

End If

Next

End Sub

Aucun commentaire:

Enregistrer un commentaire