LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default IF ... ELSE HELP please

I can't get my if statements correct... desArray(0 to 2) never changes,
but srcArray, might not
have a str1 or str2 but only str3 or it can be that there is only str1
and non of the others.
How do i account for those combinations? I used a boolean, but i can't
get it to work. Is there another way i can do this? My basic need is if
the str1 is found 1st then it adds the sheet and renames. If str2 and
str3 is not found, i don't need to add another sheet, just process.
If str1 is not found, i need to continue with the loop, and it doesn't
need to add the sheet yet. If str2 is found then at that point add the
sheet and rename it. I str3 is not found, continue processing. If
Str1,str2 is not found continue with loop, if str3 is found, add a
sheet and rename it. See below where i commented out. thanks for any
suggestions.

Keri~

srcArray(0)="str1"
srcArray(1)="str2"
srcArray(2)="str3"
desArray(0)="str1A"
desArray(1)="str2A"
desArray(2)="str3A"

For i = 0 To 2
With searchRange
WhatToFind = srcArray(i)
Set FindFirst = .Find(What:=WhatToFind, _
LookIn:=xlValues,
LookAt:=xlWhole, _
after:=.Cells(.Cells.Count),
_
SearchDirection:=xlNext)
If FindFirst Is Nothing Then
MsgBox "Nothing found"
W = False
GoTo nextI
End If

.... do some stuff

strGroup = desArray(i)
Set FoundCell = Cells.Find(strGroup, _
LookIn:=xlValues,
LookAt:=xlWhole)

If i = 0 And W = True Then
dSheet.Copy after:=.Item(.Count)
ActiveSheet.Name = theName
End If

' If i = 1 And W = False Then
' dSheet.Copy after:=.Item(.Count)
' ActiveSheet.Name = theName
' End If
' If i = 2 And W = False Then
' dSheet.Copy after:=.Item(.Count)
' ActiveSheet.Name = theName
' End If

NextI:
Next i

 
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



All times are GMT +1. The time now is 07:15 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"