+ Reply to Thread
Results 1 to 5 of 5

Changing string of character into a formula

  1. #1
    Registered User
    Join Date
    05-07-2014
    Location
    Detroit
    MS-Off Ver
    Excel 2013
    Posts
    3

    Changing string of character into a formula

    Hello,

    I am currently working on a file from the Census 2000 which consists on a list of the most popular surname in the US, and the distribution of their race (6 different output (columns)) (roughly 150.000 data lines). Unfortunately, when the probability is very small, the cell contains a "(S)".

    For the continuation of my work, I need to change those (S) -that are let's say randomly dispatched all the way through- by a probability. I want to compute this probability to be (1-(sum of cells that doesn't contain (S)in the row))/(numbers of cells that contain (S) in the row).

    By example, if we have for a given name the following distribution (columns) : 1,21% (S) 93,31% (S) 4,45% 0,85%
    I would like, for this row, to change the (S) by (1-(0.9331+0.0121+0.0445+0.0085))/2 = 0.0009

    Since the (S) could be in any row, and there could be from 1 to 5 of them in each, I have absolutely no clue how to compute a formula to apply to this huge data file.

    Thank you very much for your help

    Regards.
    Last edited by Wark; 05-07-2014 at 10:40 PM.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Changing string of charater into a formula

    I don't think we can come up with a formula to do this. A VBA macro would be the way to go. Is this a possible solution for you?
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    05-07-2014
    Location
    Detroit
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Changing string of charater into a formula

    I haven't used VBA macros since college and it was very basic, but google is my friend, so that could work !

    I believe I have to create some kind of loop that check row by row for (S) values, then count the number of values in the row, then apply the formula and replace?

    not sure how to do that...

    thank you

  4. #4
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: Changing string of character into a formula

    For each row you could have =(1-SUMIF(A1:F1,"<>S"))/COUNTIF(A1:F1,"S"). Assuming that formula was in G1:G150000 you would then need to recreate the data, maybe in column H, so in H1 you would have =IF(A1="S",$G1,A1). Drag that across to column M (you said there were 6 columns) and down (all 150k data lines). Then copy, paste special, values over the original data and delete columns H-M. Adjust columns to suit your actual data.

  5. #5
    Registered User
    Join Date
    05-07-2014
    Location
    Detroit
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Changing string of character into a formula

    Thank you very much, it worked !
    I just had to change =(1-SUM(B2:G2))/COUNTIF(B2:G2,"(S)") instead of =(1-SUMIF(A1:F1,"(S)"))/COUNTIF(A1:F1,"(S)")

    don't really know why it didn't work at first, but I got it done. Thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Counting occurances of a charater in a cell or array
    By Bptacek in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-27-2014, 02:33 PM
  2. Formula to find multiple lower case charater
    By prashantsd in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-11-2012, 06:17 AM
  3. [SOLVED] Data Copy with a special charater added in
    By aviatecar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-13-2012, 07:45 PM
  4. Changing a string within a string
    By wilsonca in forum Excel General
    Replies: 1
    Last Post: 07-30-2008, 08:25 PM
  5. [SOLVED] how to add a charater in front of part number
    By chiuinggum in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-12-2006, 02:45 PM

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