Results 1 to 2 of 2

Recode a column using a code-key

Threaded View

  1. #1
    Registered User
    Join Date
    02-24-2015
    Location
    Sweden
    MS-Off Ver
    2007
    Posts
    1

    Recode a column using a code-key

    Hello!

    I have tried for days now to figure out a macro I want to create. I have a column with data, in numbers, these numbers I want to recode accordning to my code-key I have, i.e. 1 = A, 2 = B and so on. Could be something else like 1 = Sweden, 2 = The US...

    I use Userform for this, I have my example in the attached file. I really hope someone can help me with this. In the last sheet in the workbook I have come up with how the two functions look like.

    In Sheet 1 I have the code-key in the first column that I renamed to CodeKey.

    The code I have so far is:

    Private Sub RecodeNow_Click()
    'In the column that the person types in, where the cells
    'in this column matches the values to the left of "=" in column CodeKey
    'replace the cells in the typed column to the value to the right of "="
    'in the column CodeKey.

    'A2 should be CodeKey
    '=RIGHT(A2;LEN(A2)-FIND("=";A2)-1)
    '=MID(A2;1;FIND(" =";A2;1)-1)

    Dim cell As Range
    Dim TheColumn As Range
    
    For Each cell In TheColumn
        If cell.Value = MID(Range("TheColumn").Value;1;FIND(" =";Range("TheColumn").Value;1)-1) Then
        cell.Value = RIGHT(Range("CodeKey").Value;LEN(Range("CodeKey").Value)-FIND("=";Range("Kodnyckel").Value)-1)
        End If
        Next cell
    End Sub
    Someone help me
    Attached Files Attached Files
    Last edited by PetraR; 03-15-2015 at 01:16 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] this code lockes only one column can i lock more than one column using this code
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-01-2014, 03:22 AM
  2. HELP: Recode macro for sending email via lotus notes
    By sunilwadhwa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-26-2012, 02:11 PM
  3. Recode string into number on condition
    By AGA in forum Excel General
    Replies: 2
    Last Post: 12-08-2010, 02:10 PM
  4. Excel 2007 : recode across files to anonymize
    By strawbearlyjamms in forum Excel General
    Replies: 2
    Last Post: 01-22-2010, 05:43 AM
  5. how do I recode a likert scale
    By merlin in forum Excel General
    Replies: 3
    Last Post: 09-26-2005, 06:05 AM

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