+ Reply to Thread
Results 1 to 7 of 7

Converting Comma and Dash-Separated Number Strings to Binary

  1. #1
    Registered User
    Join Date
    01-10-2017
    Location
    UK
    MS-Off Ver
    2013
    Posts
    23

    Converting Comma and Dash-Separated Number Strings to Binary

    Good morning my fine Excel friends. Excel Washington here with a burning desire for a solution to a problem that's probably simple but I can't see it.

    At its most basic, I'm looking to convert text/number string into a binary-style format. I work with timetable data, and ideally I receive timetable data from the clients with which I work, with the binary week of each booking (one row represents one timetable booking) already included within the spreadsheet. Clients to like to send over some crazy data exports, however, so lots of the time I end up with weeks represented as numbers or strings of text/numbers.

    The attached spreadsheet contains a rough template of the data format I work with.

    The blue column in the first tab represents the kind of number strings I'm looking to convert, and the Peach column is the outcome I'm looking to achieve. 52 weeks in the year, 0s representing the non-booked weeks, 1s representing the weeks I'm looking to extract from the number string.

    It gets more complex considering there are some weeks separated by dashes, which require that all weeks in-between and inclusive of those numbers are also represented as 1s in the binary format (16-20 would be weeks 16,17,18,19,and 20 being 1's for example). I have no clue how to achieve this

    The other tab contains the very crude attempt I made at a solution, which once included IfIsnumbers and searches, but to no avail so I gave up on this.

    Is there anyone here that could potentially provide a formula-based solution that could be copied/pasted easily and used for future versions of this very same problem?

    My gratitude would be eternal
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,176

    Re: Converting Comma and Dash-Separated Number Strings to Binary

    Try this code
    Please Login or Register  to view this content.
    Use:

    =MyConvert2Bin(K2)
    Attached Files Attached Files
    Last edited by Phuocam; 03-01-2019 at 06:42 AM.

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Converting Comma and Dash-Separated Number Strings to Binary

    You can do this quite effectively with Power Query:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Olly; 03-01-2019 at 06:52 AM.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  4. #4
    Registered User
    Join Date
    01-10-2017
    Location
    UK
    MS-Off Ver
    2013
    Posts
    23

    Re: Converting Comma and Dash-Separated Number Strings to Binary

    Thank you Phuocam, this solution works for me, only with one issue.

    The code doesn't seem to recognize number strings that consist solely of two numbers with a dash between (eg. 14-18), however is fine with all other combinations.

    I've attached a picture to demonstrate the issue.

    If this is fixed then this will be a complete solution

    Many thanks
    Attached Images Attached Images

  5. #5
    Registered User
    Join Date
    01-10-2017
    Location
    UK
    MS-Off Ver
    2013
    Posts
    23

    Re: Converting Comma and Dash-Separated Number Strings to Binary

    Hi Olly,

    Thanks for your reply. I'll also give that a go. I'll need to read your Power Query guide first though.

    Many thanks

  6. #6
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,176

    Re: Converting Comma and Dash-Separated Number Strings to Binary

    I have updated the file in post # 2

  7. #7
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,176

    Re: Converting Comma and Dash-Separated Number Strings to Binary

    Or try:
    Please Login or Register  to view this content.

+ 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] Combine comma separated strings
    By JimmyA in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-09-2016, 01:21 PM
  2. Count number appear in single column with comma separated
    By cheeyap91 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-29-2014, 12:38 AM
  3. [SOLVED] Separated first string which is separated by dash (-) or underscore (_) or space ( )
    By nur2544 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-03-2014, 10:32 AM
  4. [SOLVED] Converting coloumns to rows + concatenate them separated by a comma
    By richardo7 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-16-2013, 11:19 AM
  5. Count number of occurrences separated by comma
    By Niclal in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2013, 03:39 AM
  6. Excel 2007 Adding Number Separated by a Dash
    By tnoble17 in forum Excel General
    Replies: 1
    Last Post: 01-16-2010, 10:07 AM
  7. [SOLVED] Count comma separated numbers, numbers in a range with dash, not t
    By Mahendra in forum Excel General
    Replies: 0
    Last Post: 08-08-2005, 01:05 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