Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default select case help

in this case my case is a string (see what I did there???)

I want to test if case contains substrings but am coming up blank.

logic im trying to follow

case contains "**No PDF**"
'do stuff
case contains "**No Final Package**"
'do different stuff
else
'do other different stuff


I've done this with nested if/elseif/else statements, but I'm looking for something a little more 'elegant'? make sense? call me a coding snob... Haha. just trying to learn new stuff.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default select case help

Hi,

to use the Like operator in a Select Case, you must add a True expression.

Sub Case_Like()
word = "is No PDF"
Select Case True
Case word Like "**No PDF**"
MsgBox "goog"
Case Else
MsgBox "no good"
End Select
End Sub

isabelle

Le 2016-12-14 Ã* 12:24, Matthew Dyer a écrit :
in this case my case is a string (see what I did there???)

I want to test if case contains substrings but am coming up blank.

logic im trying to follow

case contains "**No PDF**" 'do stuff case contains "**No Final Package**" 'do
different stuff else 'do other different stuff


I've done this with nested if/elseif/else statements, but I'm looking for
something a little more 'elegant'? make sense? call me a coding snob... Haha.
just trying to learn new stuff.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default select case help

Hi Matthew,

Am Wed, 14 Dec 2016 09:24:22 -0800 (PST) schrieb Matthew Dyer:

case contains "**No PDF**"
'do stuff
case contains "**No Final Package**"
'do different stuff
else
'do other different stuff


another suggestion:

varCheck = Array("No PDF", "No Final Package")

For Each rngC In Range("A1:A10")
For i = LBound(varCheck) To UBound(varCheck)
If InStr(rngC, varCheck(i)) Then Exit For
Next
Select Case i
Case 0
MsgBox " no PDF"
Case 1
MsgBox "no package"
Case Else
MsgBox "Other"
End Select
Next


Regards
Claus B.
--
Windows10
Office 2016
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
Case not recognized in Select Case kevlarmcc Excel Programming 4 March 29th 10 07:40 PM
Select Case jlclyde Excel Discussion (Misc queries) 5 January 6th 09 10:05 PM
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
End Select without Select Case, Block If without End If errors Atreides Excel Programming 12 November 17th 06 06:10 PM


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

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

About Us

"It's about Microsoft Excel"