Need help with to assign numerical value to a particular set of data

Euro_87

New Member
Joined
Jun 26, 2016
Messages
1
Hi,

I am working with a set of data, which cannot be uploaded unless I convert it to a particular numeric value.

I am dealing with more than 20 such data sets spread across different cells. For example, as shown below, you will find some common datasets - AR, AF, Web, PR. Now, every dataset has a unique code, for instance - AR = 9, AF = 21, PR = 35 and Web = 13. Now what could be the best macro to use that will allow me to convert my dataset into the numerical values. Can any one please help me out with it.

KegBondPieOff
ARAFWebPR
WebPRARAF
WebPRARAF
WebPRARAF
WebPRWebPR
PRARAFPR
WebPRWebPR
ARWebPRNA

<colgroup><col width="64" span="4" style="width:48pt"> </colgroup><tbody>
</tbody>

Regards,
Euro_87
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Assuming all your data is in the columns A:D then the following code would work

Code:
Option Explicit


Sub ams626()
    Dim c As Range
    Dim lr As Long
    Dim rng As Range
    lr = Range("A" & Rows.Count).End(xlUp).Row
    Set rng = Range("A2:D" & lr)
    For Each c In rng
        If c = "AF" Then
            c = 21
        ElseIf c = "AR" Then
            c = 9
        ElseIf c = "PR" Then
            c = 35
        ElseIf c = "Web" Then
            c = 13
        End If
    Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,613
Messages
6,125,834
Members
449,266
Latest member
davinroach

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top