+ Reply to Thread
Results 1 to 6 of 6

Translate yes or no to digit and summarize in YTD sheet

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Translate yes or no to digit and summarize in YTD sheet

    Hello:

    I have excel workwook with Month sheet Jan,Feb,Mar....Dec and YTD

    In each monthly sheet i will have either "yes"or "No" in cell B66:K75.

    Below is what i need to do in YTD sheet cell B66:K75.
    Each cell in TYD B66:K75 will have 12 digit number

    Need to go thru each monthly sheet for each of the above cell and find if Yes or No and translate that into number (yes = 1, no = 0)

    Example:

    If B66 in Jan, Feb and Mar is Yes and B66 in Apr thru Dec is No then the number in YTD in cell B66=111000000000



    Let me Know if you have any questions.
    Thanks.
    Riz

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,947

    Re: Translate yes or no to digit and summarize in YTD sheet

    For the first part of your request, here is some untested code, as you did not provide a sample worksheet:
    Option Explicit
    
    Sub Riz()
        Dim w As Worksheet
        Dim c As Range
        Dim rng As Range
        Set rng = Range("B66:K75")
    Application.ScreenUpdating = False
    
        For Each w In Worksheets
            If w.Name <> "YTD" Then
                For Each c In rng
                If c.Text = "Yes" Then
                c.Value = 1
                Else: c.Value = 0
                End If
                Next c
            End If
        Next w
    Application.ScreenUpdating = True
    MsgBox "completed"
    
    End Sub
    I believe that you can do a simple concatenate in the YTD sheet and copy it down and over. Really no need for any VBA as it is a simple formula to be copied
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Translate yes or no to digit and summarize in YTD sheet

    Hi,
    Here are 2 proposal :

    With a formula. Example in B66 = YTD(B66)
    (note that it does not refresh automatically)
    Function YTD(rg As Range) As String
        Dim arSh, i
        Application.Volatile
    
        arSh = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
        arSh = Split(arSh, ",")
    
        On Error Resume Next    '(in case a sheet is not found)
        For i = LBound(arSh) To UBound(arSh)
            YTD = YTD & IIf(Sheets(arSh(i)).Range(rg.Address) = "Yes", 1, 0)
        Next i
        On Error GoTo 0
    
    End Function
    Or with a sub
    (Adjust range / sheet names are necessary)

    Sub YTD2()
        Dim arSh, i
        Dim rg As Range, c As Range
        Dim sYTD As String
        Application.Volatile
    
        arSh = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
        arSh = Split(arSh, ",")
    
        Set rg = Sheets("YTD").Range("B66:K75")
        For Each c In rg
            sYTD = "'"
            On Error Resume Next    '(in case a sheet is not found)
            For i = LBound(arSh) To UBound(arSh)
                sYTD = sYTD & IIf(Sheets(arSh(i)).Range(c.Address) = "Yes", 1, 0)
            Next i
             On Error GoTo 0
            c.Value = sYTD
        Next c
    End Sub
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  4. #4
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Translate yes or no to digit and summarize in YTD sheet

    Hello:

    It seems to work great, except when I run the code the number's have small triangle for error.
    I would like to convert the range B66: K75 in number and IGNORE ERROR.
    Please refer to attached pic
    Is this possible.
    Thanks
    Riz
    Attached Images Attached Images

  5. #5
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Translate yes or no to digit and summarize in YTD sheet

    Hello GC Excel:

    It looks like YTD sub will work.
    Let me test and i will let you know if any issues.
    Thanks a lot for your great help.
    Riz

  6. #6
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Translate yes or no to digit and summarize in YTD sheet

    Hello GC Excel:

    I got it by adding below code:

    Application.ErrorCheckingOptions.NumberAsText = False
    Once again I thank you for great help.

    Riz

+ 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] LOTTERY FILTER#4, Find if 1 Digit Sum of 2 Digit or 3 Digit, Single Cell w/ dash
    By david gonzalez in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-08-2014, 12:57 AM
  2. Sample Translate English to Arabic Text Using MS Translate
    By pidyok in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-21-2013, 08:18 AM
  3. Summarize Sheets onto one Sheet / Create New Sheet from Template with Button
    By albizzundy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-12-2013, 01:33 PM
  4. translate 'days, hours, mins' calculation from sheet to VBA
    By rawtech in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-07-2011, 02:24 AM

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