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
Bookmarks