1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Other Excel forumula/macro help

Discussion in 'Software' started by goldstar0011, 24 Sep 2019.

  1. goldstar0011

    goldstar0011 Multimodder

    Joined:
    2 Sep 2007
    Posts:
    3,669
    Likes Received:
    487
    Howdy

    Trying to make dummies coding guide f but am struggling to code something up.

    In short I need to make a sheet to make a 7 digit code, I was planning to have 7 columns and when the user clicks the appropriate label in the column it generates a digit at the top, once they have done all 7 it will concatenate them into 1 long code.

    I would be great if I can have each selection highlight and but needs to be able to have selections change.

    Any experts able to direct me here

    Cheers
     
  2. Midlight

    Midlight Minimodder

    Joined:
    6 Jun 2011
    Posts:
    353
    Likes Received:
    185
    The below was set for a range of values in C3 to I9. It turns the selection green and puts a value in row 1, corresponding to the numerical position in the list. When 7 values are present you get a 7 digit number in K1.
    Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim irow As Integer
    Dim icol As Integer
    
        If Selection.Count = 1 Then
            If Not Intersect(Target, Range("C3:I9")) Is Nothing Then
                Let irow = ActiveCell.Row
                Let icol = ActiveCell.Column
                Cells(1, icol) = irow - 2
                Range(Cells(3, icol), Cells(9, icol)).Interior.ColorIndex = 0
                ActiveCell.Interior.ColorIndex = 4
                If WorksheetFunction.CountA(Range("C1:I1")) = 7 Then
                    Range("K1") = "=C1&D1&E1&F1&G1&H1&I1"
                Else
                    Range("K1").ClearContents
                End If
            End If
        End If
    End Sub
     
    Shirty likes this.
  3. goldstar0011

    goldstar0011 Multimodder

    Joined:
    2 Sep 2007
    Posts:
    3,669
    Likes Received:
    487
    Wow, just wow!
    Thank you
     

Share This Page