Results 1 to 9 of 9

Scanning for shifted values in different columns

Threaded View

  1. #5
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Scanning for shifted values in different columns

    If interested in VBA:
    Sub PositionLetters()
    Dim colB As Variant, colC As Variant
    Dim colBCnt As Long, colCCnt As Long
    Dim colBArray(1 To 26) As String
    Dim colCArray(1 To 26) As String
    Dim x As Long, y As Long, z As Long
    Dim fndCnt As Long
    x = 1
    For Each colB In Sheets(1).Range("B2:B27")
        colBArray(x) = colB.Value
        x = x + 1
    Next colB
    y = 1
    For Each colC In Sheets(1).Range("C2:C27")
        colCArray(y) = colC.Value
        y = y + 1
    Next colC
    For x = 1 To 26
           y = 1
            If colCArray(x) <> colBArray(x) Then
                Do Until colCArray(y) = colBArray(x)
                    y = y + 1
                Loop
                If y > x Then z = x - y
                If y < x Then z = x - y
                Set fndrng = Sheets(1).Range("C2:C27").Cells.Find(colCArray(x)).Offset(0, 1)
                fndrng.Value = z
            End If
    Next x
    End Sub
    Last edited by Mordred; 06-14-2011 at 02:23 AM.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

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