Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: execute operation with a selection

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I wanna be able to select some cells, and then execute some operation regarding each cell in the selection for example set each cell content uppercase. I manage to write a code for setting any activecell content as uppercase, but fail to do it for a selection.


  2. #2
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Try the following code by putting it in the code for your worksheet:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Address = "$F$4:$G$4" Then
    Target.Value = UCase(Target.Text)
    End If
    End Sub

    Subsitute "$F$4:$G$4" with your range, formatted the same way.
    Best regards,
    Allan Chara
    http://www.mrspreadsheets.com

  3. #3
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Bogota, Colombia
    Posts
    11,959
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    You can use a for each statement, like

    Dim Cll as Range
    For each Cll in Selection
    'do my stuff with the Cell "Cll"
    Next Cll
    Regards,

    Juan Pablo González
    http://www.juanpg.com

  4. #4
    New Member
    Join Date
    Mar 2002
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanx Juan Pablo,

    It helped me for 100%. I'am not professional in programming, so I ve been searching for this facility for several months.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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