Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Multiple If Statement problem

I am cutting a PO an trying to save it based on the account or project
number. Here is part of the code:

Dim POFname as String
If Len(Range("F39").Value) = 12 Then
POFname = "PO " & Range("D6").Value & " for Store " &
Right(Range("F39").Value, 4) & ".xls"
'If Len(Range("F39").Value) = 18 Then
'POFname = "PO " & Range("D6").Value & " for Project " &
Left(Range("F39").Value, 6) & ".xls"
'If Len(Range("F39").Value) = 11 Then

POFname = "PO " & Range("D6").Value & " for Dept " &
Right(Range("F39").Value, 3) & ".xls"
'End If
'End If
End If

ActiveWorkbook.SaveAs FileName:=("C:\Documents and Settings\gregr\My
documents\POs\") & _
POFname

It all works as expected except if I uncomment the If statement that
relates to project. F39 value can be any of these formats:

xxx-xxx-xxx (Dept)
xxx-xxx-xxxx (Store)
xx-xxx-xxx-xxx-xxx (project)

The expect file name results should be:
PO xxxx for Dept xxx
PO xxxx for Project xx-xxx
PO xxxx for Store xxxx

TIA

Greg

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Multiple If Statement problem

try this out

Sub test()

Dim POFname As String
If Len(Range("f39")) = 12 Then
POFname = "PO " & Range("D6").Value & " for Store " & _
Right(Range("f39").Value, 4) & ".xls"

ElseIf Len(Range("f39")) = 18 Then
POFname = "PO " & Range("D6").Value & " for Project " & _
Left(Range("f39").Value, 6) & ".xls"

ElseIf Len(Range("f9")) = 11 Then
POFname = "PO " & Range("D6").Value & " for Dept " & _
Right(Range("f39").Value, 3) & ".xls"

End If
Debug.Print POFname

End Sub


--


Gary


"GregR" wrote in message
oups.com...
I am cutting a PO an trying to save it based on the account or project
number. Here is part of the code:

Dim POFname as String
If Len(Range("F39").Value) = 12 Then
POFname = "PO " & Range("D6").Value & " for Store " &
Right(Range("F39").Value, 4) & ".xls"
'If Len(Range("F39").Value) = 18 Then
'POFname = "PO " & Range("D6").Value & " for Project " &
Left(Range("F39").Value, 6) & ".xls"
'If Len(Range("F39").Value) = 11 Then

POFname = "PO " & Range("D6").Value & " for Dept " &
Right(Range("F39").Value, 3) & ".xls"
'End If
'End If
End If

ActiveWorkbook.SaveAs FileName:=("C:\Documents and Settings\gregr\My
documents\POs\") & _
POFname

It all works as expected except if I uncomment the If statement that
relates to project. F39 value can be any of these formats:

xxx-xxx-xxx (Dept)
xxx-xxx-xxxx (Store)
xx-xxx-xxx-xxx-xxx (project)

The expect file name results should be:
PO xxxx for Dept xxx
PO xxxx for Project xx-xxx
PO xxxx for Store xxxx

TIA

Greg



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Multiple If Statement problem

try this out

Sub test()

Dim POFname As String
If Len(Range("f39")) = 12 Then
POFname = "PO " & Range("D6").Value & " for Store " & _
Right(Range("f39").Value, 4) & ".xls"

ElseIf Len(Range("f39")) = 18 Then
POFname = "PO " & Range("D6").Value & " for Project " & _
Left(Range("f39").Value, 6) & ".xls"

ElseIf Len(Range("f9")) = 11 Then
POFname = "PO " & Range("D6").Value & " for Dept " & _
Right(Range("f39").Value, 3) & ".xls"

End If
Debug.Print POFname

End Sub


--


Gary


"GregR" wrote in message
oups.com...
I am cutting a PO an trying to save it based on the account or project
number. Here is part of the code:

Dim POFname as String
If Len(Range("F39").Value) = 12 Then
POFname = "PO " & Range("D6").Value & " for Store " &
Right(Range("F39").Value, 4) & ".xls"
'If Len(Range("F39").Value) = 18 Then
'POFname = "PO " & Range("D6").Value & " for Project " &
Left(Range("F39").Value, 6) & ".xls"
'If Len(Range("F39").Value) = 11 Then

POFname = "PO " & Range("D6").Value & " for Dept " &
Right(Range("F39").Value, 3) & ".xls"
'End If
'End If
End If

ActiveWorkbook.SaveAs FileName:=("C:\Documents and Settings\gregr\My
documents\POs\") & _
POFname

It all works as expected except if I uncomment the If statement that
relates to project. F39 value can be any of these formats:

xxx-xxx-xxx (Dept)
xxx-xxx-xxxx (Store)
xx-xxx-xxx-xxx-xxx (project)

The expect file name results should be:
PO xxxx for Dept xxx
PO xxxx for Project xx-xxx
PO xxxx for Store xxxx

TIA

Greg



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Multiple If Statement problem

Dim POFname as String
If Len(Range("F39").Value) = 12 Then
POFname = "PO " & Range("D6").Value & " for Store " & _
Right(Range("F39").Value, 4) & ".xls"
Elseif Len(Range("F39").Value) = 18 Then
POFname = "PO " & Range("D6").Value & " for Project " & _
Left(Range("F39").Value, 6) & ".xls"
Elseif Len(Range("F39").Value) = 11 Then
POFname = "PO " & Range("D6").Value & " for Dept " & _
Right(Range("F39").Value, 3) & ".xls"
End If


--
Regards,
Tom Ogilvy


"GregR" wrote in message
oups.com...
I am cutting a PO an trying to save it based on the account or project
number. Here is part of the code:

Dim POFname as String
If Len(Range("F39").Value) = 12 Then
POFname = "PO " & Range("D6").Value & " for Store " &
Right(Range("F39").Value, 4) & ".xls"
'If Len(Range("F39").Value) = 18 Then
'POFname = "PO " & Range("D6").Value & " for Project " &
Left(Range("F39").Value, 6) & ".xls"
'If Len(Range("F39").Value) = 11 Then

POFname = "PO " & Range("D6").Value & " for Dept " &
Right(Range("F39").Value, 3) & ".xls"
'End If
'End If
End If

ActiveWorkbook.SaveAs FileName:=("C:\Documents and Settings\gregr\My
documents\POs\") & _
POFname

It all works as expected except if I uncomment the If statement that
relates to project. F39 value can be any of these formats:

xxx-xxx-xxx (Dept)
xxx-xxx-xxxx (Store)
xx-xxx-xxx-xxx-xxx (project)

The expect file name results should be:
PO xxxx for Dept xxx
PO xxxx for Project xx-xxx
PO xxxx for Store xxxx

TIA

Greg



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Multiple If Statement problem

Tom and Gary, thank you very much

Greg



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 statement with multiple criteria and multiple results Tickfarmer Excel Discussion (Misc queries) 3 January 28th 09 08:11 PM
Problem with If Statement MarkFrost39 Excel Worksheet Functions 0 September 6th 07 02:48 PM
If Statement Problem Brandy Excel Discussion (Misc queries) 2 May 3rd 06 04:33 PM
IF statement problem simon Excel Worksheet Functions 1 December 30th 04 10:59 AM
IF statement problem Jim Robinson Excel Programming 1 May 1st 04 09:08 PM


All times are GMT +1. The time now is 01:35 PM.

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"