+ Reply to Thread
Results 1 to 22 of 22

code to insert dash sign

Hybrid View

  1. #1
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: code to insert dash sign

    Replace all the code in the sheet module with this:
    Option Explicit
    Public Prior As String
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
        If Target.Column = 6 Then Prior = Target.Text
    
    End Sub
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cell As Range
    
    For Each cell In Target
        If cell.Column = 6 Then
            Select Case cell.Value
                Case "Company", "Organization", "School", "S. S. C. board"
                    Application.EnableEvents = False
                    Range("Q" & cell.Row).Resize(, 9).Value = "-"
                    Application.EnableEvents = True
                Case Else
                    Select Case Prior
                        Case "Company", "Organization", "School", "S. S. C. board"
                            Application.EnableEvents = False
                            Range("Q" & cell.Row).Resize(, 9).Value = ""
                            Application.EnableEvents = True
                        Case Else
                            'do nothing
                    End Select
            End Select
        End If
    Next cell
    
    End Sub
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  2. #2
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: code to insert dash sign

    Good morning JBeaucaire,
    Excellent! it's working fine. Now I think to add background music to my contacts file. is it possible through vba? I want to make my contact file more dynamic so I'm modifying it day by day. If you have any suggestions to make it more dynamic and informative I appreciate your suggestions.

    I want to keep contact with you regularly as my best friend. I like to make friendship with such a brilliant personalities.

    (Moderator's edit - personal contact info removed as per forum rules)

    Thanking you in anticipation.

    Mukesh
    Attached Files Attached Files
    Last edited by JBeaucaire; 07-06-2013 at 10:47 PM. Reason: Removed personal information from public thread, as per forum rules.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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