#1   Report Post  
Posted to microsoft.public.excel.programming
bob bob is offline
external usenet poster
 
Posts: 16
Default if statment

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default if statment

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

--

HTH

Bob Phillips

"bob" wrote in message
. ca...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Statment Momo Excel Worksheet Functions 2 December 6th 08 02:24 PM
Help with If statment pm Excel Discussion (Misc queries) 3 January 29th 08 04:09 PM
If statment Jason Excel Discussion (Misc queries) 3 January 3rd 08 11:39 PM
if statment Dreamstar_1961 Excel Worksheet Functions 5 April 17th 07 01:30 PM
If statment helpdesk genie Excel Worksheet Functions 2 January 12th 05 03:23 AM


All times are GMT +1. The time now is 03:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"