Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CM CM is offline
external usenet poster
 
Posts: 136
Default multiple value choices for If range().value = "xxx"

The macro below runs on worksheet change and works properly.

However, I have 5 values to examine in column H. The values a Split,
Payday 1, Payday 2, Payday 3, and Payday 4. Any of these choices should
result in unlocking and clearing the cells in that row (first part of if
statement). Otherwise, the range 'pasterage' is copied to that row and it is
locked again. I can't find the proper syntax (if there is any) to say
something like is possible in SQL (if ...value in ("Split","Payday 1",...))
Please advise on the best way to go about this.

n = Target.Row
If Me.Range("H" & n).Value = "Split" Then
Me.Range("I" & n & ":W" & n).Locked = False
Me.Range("I" & n & ":W" & n).ClearContents
Else
Me.Range("I" & n & ":W" & n).Locked = True
Range("pasterange").Copy
Range("I" & n).PasteSpecial Paste:=xlPasteFormulas, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

End If
--
thanks for your assistance
cm
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default multiple value choices for If range().value = "xxx"

There is no "value in ()" syntax.

You can use this:
Select Case Range("H" & n).Value
Case "Split", "Payday 1", "Payday2"
[do something]
Case "Payday 3", "Payday4"
[do something else]
End Select

Or this:
If Instr("Split Payday 1 Payday2", Range("H" & n).Value) Then

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
How do I get rid of "Top 10" and "Custom" choices Autofilter? JosiePosie21 Excel Worksheet Functions 2 March 17th 06 07:30 PM
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" Luc[_3_] Excel Programming 2 September 28th 05 08:37 PM
Multiple "Range" with "Cells" property? jopu[_2_] Excel Programming 3 November 18th 04 04:05 PM
Multiple "Range" with "Cells" property? jopu Excel Programming 2 November 18th 04 02:38 PM
Using "Cells" to write "Range("A:A,H:H").Select" Trip Ives[_2_] Excel Programming 3 June 5th 04 03:13 PM


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