Select Case question

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,404
Office Version
  1. 2016
Platform
  1. Windows
I'm using this to try to update cells automatically but it is not doing what I need;

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Range("D7").Value = "" Then
Select Case Range("D7").Value
Case Is > 8
Range("E7").Value = "Current"
End Select
Else
Select Case Range("D7").Value
Case Is < 1
Range("E7").Value = "Expired"
Case 1 To 8
Range("E7").Value = "Due to Expire"
End Select
End If

End Sub

The cell in E7 has Data Validation List and what I need is it to allow any value from that list if D7 is empty, (D7 contains a formula which does give "" if the source cell is empty). What is happening is that E7 is defaulting to 'Current'.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Try

Code:
If CStr(Range("D7").Value) <> "" Then
    Select Case Val(CStr(Range("D7").Value))
        Case Is < 1 Then
            Range("E7").Value = "Expired"
        Case Is < 8 Then
            Range("E7").Value = "Due To Expire"
        Case Else
            Range("E7").Value = "Current"
    End Select
End If
 
Upvote 0
Thanks Mike, but I get a syntax error with this line highlighted;

Code:
Case Is < 1 Then
 
Upvote 0

Forum statistics

Threads
1,213,567
Messages
6,114,344
Members
448,570
Latest member
rik81h

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top