Consulting

Results 1 to 14 of 14

Thread: VBA to replace numerical data with Alphnumerical data.

  1. #1
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location

    VBA to replace numerical data with Alphnumerical data.

    So I need a Macro to simply replace the numerical data that is in column E with the alpha numeric associated with each number in the combination in column E.
    in column A are the numbers 1 to 35 these will never change.
    the alpha numeric in column B will change on occasion so VBA needs to work with new data.
    in column B there are alpha numeric that are associated with the numbers in column A.
    in column E there is a 5 number combination that made up of the numbers 1 to 35 and delimited.
    these combinations are then unmerged to the columns G H I J K. the columns M N O P Q will be where the alpha numeric replacing the numbers will be placed.

    if any questions please ask, I am attaching example.
    Thank you!
    Last edited by estatefinds; 03-31-2016 at 09:29 AM.

  2. #2
    VBAX Tutor PAB's Avatar
    Joined
    Nov 2011
    Location
    London (UK)
    Posts
    243
    Location
    Hi Dennis,

    I think the data values you have in cells P2 (should be value C5), Q5 (should be value E16, there is NO E9), P10 (should be value C2) are wrong.

    Put this formula in cell M2 and copy it across and down.

    =VLOOKUP(G2,$A$2:$B$35,2)
    I hope this helps!
    Last edited by PAB; 03-31-2016 at 01:17 PM.
    -----------------------------------------∏-

    12:45, restate my assumptions.
    Mathematics is the language of nature.
    Everything around us can be represented and understood through numbers.
    If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

    -----------------------------------------∏-

  3. #3
    VBAX Tutor PAB's Avatar
    Joined
    Nov 2011
    Location
    London (UK)
    Posts
    243
    Location
    Did that work and do what you want Dennis?
    -----------------------------------------∏-

    12:45, restate my assumptions.
    Mathematics is the language of nature.
    Everything around us can be represented and understood through numbers.
    If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

    -----------------------------------------∏-

  4. #4
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    Running it now, thank you!

  5. #5
    VBAX Tutor PAB's Avatar
    Joined
    Nov 2011
    Location
    London (UK)
    Posts
    243
    Location
    You're welcome.
    -----------------------------------------∏-

    12:45, restate my assumptions.
    Mathematics is the language of nature.
    Everything around us can be represented and understood through numbers.
    If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

    -----------------------------------------∏-

  6. #6
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    Ok so I added my data and it takes a long time it's still running, is there anyway this can be done in macros?

  7. #7
    VBAX Tutor PAB's Avatar
    Joined
    Nov 2011
    Location
    London (UK)
    Posts
    243
    Location
    Quote Originally Posted by estatefinds View Post
    OK, so I added my data and it takes a long time, it's still running, is there anyway this can be done in macros?
    I can't understand why it is taking a long time to run because they are only formulas?
    How much data are we talking about?
    -----------------------------------------∏-

    12:45, restate my assumptions.
    Mathematics is the language of nature.
    Everything around us can be represented and understood through numbers.
    If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

    -----------------------------------------∏-

  8. #8
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    Over 400,000 can this be done in macros?

  9. #9
    VBAX Tutor PAB's Avatar
    Joined
    Nov 2011
    Location
    London (UK)
    Posts
    243
    Location
    Give me 5 minutes and I will post a Macro that should do what you want!
    -----------------------------------------∏-

    12:45, restate my assumptions.
    Mathematics is the language of nature.
    Everything around us can be represented and understood through numbers.
    If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

    -----------------------------------------∏-

  10. #10
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    Ok great! Thank you!

  11. #11
    VBAX Tutor PAB's Avatar
    Joined
    Nov 2011
    Location
    London (UK)
    Posts
    243
    Location
    OK Dennis, give this a go.

    Option Explicit
    Option Base 1
    Sub Replace_Num_With_Alpha()
        With Application
            .ScreenUpdating = False: .Calculation = xlCalculationManual: .DisplayAlerts = False
        End With
        Range("M2:Q" & Range("E" & Rows.Count).End(xlUp).Row).ClearContents
        Range("M2:Q" & Range("E" & Rows.Count).End(xlUp).Row).Formula = _
            "=VLOOKUP(G2,$A$2:$B$35,2)"
        Range("M2:Q" & Range("E" & Rows.Count).End(xlUp).Row).Value = _
            Range("M2:Q" & Range("E" & Rows.Count).End(xlUp).Row).Value
        With Application
            .DisplayAlerts = True: .Calculation = xlCalculationAutomatic: .ScreenUpdating = True
        End With
    End Sub
    Please let me know how you get on!
    -----------------------------------------∏-

    12:45, restate my assumptions.
    Mathematics is the language of nature.
    Everything around us can be represented and understood through numbers.
    If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

    -----------------------------------------∏-

  12. #12
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location
    ok i ran it and the number 35 is listed as E16 and it supposed to be E9.
    also this data will change in column B but only after I run this with the original data in column B.
    can this be fixed?

    shouldnt it be reading what is in the data column A and B as it is displayed?

    I just figured it out the code had to be to row 36 now it works like it should.

    Thank you for the code it works Great!!! and very fast Thank you!!!!

  13. #13
    VBAX Tutor PAB's Avatar
    Joined
    Nov 2011
    Location
    London (UK)
    Posts
    243
    Location
    You're welcome, thanks for the feedback.
    -----------------------------------------∏-

    12:45, restate my assumptions.
    Mathematics is the language of nature.
    Everything around us can be represented and understood through numbers.
    If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

    -----------------------------------------∏-

  14. #14
    VBAX Tutor PAB's Avatar
    Joined
    Nov 2011
    Location
    London (UK)
    Posts
    243
    Location
    Hi Dennis,

    Quote Originally Posted by estatefinds View Post
    ...also, this data will change in column B, but only after I run this with the original data in column B.
    Can this be fixed?
    If the data is going to be dynamic in columns A & B, either grow or shrink once you have run the code, then you will need to add a dynamic range variable to the code and use that.
    -----------------------------------------∏-

    12:45, restate my assumptions.
    Mathematics is the language of nature.
    Everything around us can be represented and understood through numbers.
    If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.

    -----------------------------------------∏-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •