+ Reply to Thread
Results 1 to 7 of 7

Select case using a range

Hybrid View

sigfreid Select case using a range 07-31-2009, 05:25 AM
royUK Re: Select case using a range 07-31-2009, 06:12 AM
sigfreid Re: Select case using a range 07-31-2009, 06:58 AM
StephenR Re: Select case using a range 07-31-2009, 07:10 AM
sigfreid Re: Select case using a range 07-31-2009, 07:57 AM
StephenR Re: Select case using a range 07-31-2009, 08:19 AM
sigfreid Re: Select case using a range 07-31-2009, 09:17 AM
  1. #1
    Registered User
    Join Date
    04-19-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: Select case using a range

    Quote Originally Posted by StephenR View Post
    Why not like this?
    Well primarily becuase column B is to be in Proper Case and C an D are in Upper Case, but also because I don't want it to affect the column titles.

    I did try

    Private Sub Worksheet_change(ByVal Target As Range)
        If Target.Cells.Count > 1 Then
            Exit Sub
        End If
        On Error GoTo ErrHandler:
        
        If Not Application.Intersect(Me.Range("D2:D65535"), Target) Is Nothing Then
            If IsNumeric(Target.Value) = False Then
                Application.EnableEvents = False
                Target.Value = StrConv(Target.Text, vbUpperCase)
                Application.EnableEvents = True
            End If
        End If
    
        If Not Application.Intersect(Me.Range("B2:B65535"), Target) Is Nothing Then
            If IsNumeric(Target.Value) = False Then
                Application.EnableEvents = False
                Target.Value = StrConv(Target.Text, vbProperCase)
                Application.EnableEvents = True
            End If
        End If
        
    ErrHandler:
        Application.EnableEvents = True
        
    End Sub
    But it wouldn't work, hence the cases. I'm Currently trying to tidy up the code a bit for instance, where I need C2:C65535 , D2:D65535 and say G2:G65535 in upper case is it possible to have all 3 ranges in the same case?

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Select case using a range

    Select Case Target.Column
    Case 2
    'code
    Case 3
    'code
    'etc
    End Select

  3. #3
    Registered User
    Join Date
    04-19-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: Select case using a range

    Cheers, that didn't quite do it, but got me pretty close and I've figured it out now.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1