if statment

B

bob

i am writing a macro that takes year "3" in col A and Month "AUG" in col B
and converts col A into mm/dd/yy. how would i write an if in Cl loop that
will drop down to next row if col A is not a 1 digit number. Datehold loop
works on fist table but runs into error when col A is blank or not year.

the other part is what is the correct syntax in union statement to only
include col A

For Each Cl In Union(Range(Range("A7"), Range("A7").End(xlDown)), _
Range(Range("T7"), Range("T7").End(xlDown)))
DateHold = Cl.Value + 2000
DateHold = DateValue(Cl.Offset(0, 1) & " " & DateHold)
DateHold = DateHold + 20 - Weekday(DateHold)
If Day(DateHold) < 15 Then DateHold = DateHold + 7
Cl.Value = DateHold
Next Cl

thanks
 
B

Bob Phillips

Bob,

Is this what you mean?

Sub test2()
For Each Cl In Union(Range(Range("A7"), Range("A7").End(xlDown)), _
Range(Range("T7"), Range("T7").End(xlDown)))
If IsNumeric(c1.Value) Then
If c1.Value >= 0 And c1.Value < 10 Then
DateHold = Cl.Value + 2000
DateHold = DateValue(Cl.Offset(0, 1) & " " & DateHold)
DateHold = DateHold + 20 - Weekday(DateHold)
If Day(DateHold) < 15 Then DateHold = DateHold + 7
Cl.Value = DateHold
End If
End If
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top