+ Reply to Thread
Results 1 to 12 of 12

Convert to Binary

  1. #1
    Registered User
    Join Date
    10-19-2016
    Location
    New York City, New York
    MS-Off Ver
    2015
    Posts
    13

    Convert to Binary

    Hi - I am trying convert a table to binary. I have the following code, but the only issue is that it replaces nulls with 0 if the nulls are after a 0 in the same row. I would like all nulls to stay nulls. I attached a spreadsheet as an explanation. The "Example" should change into what is shown in the "Example Output" tab. Does this make sense? Any help would be much appreciated. I think it should just be a minor tweak to this code. Thanks!

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Convert to Binary

    You have blank rows, and the current region stopped at row 10 and did not pick the rows after the blank.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-19-2016
    Location
    New York City, New York
    MS-Off Ver
    2015
    Posts
    13

    Re: Convert to Binary

    Thanks, AB33! I'm still a bit confused because the code still replaces nulls with 0 if the nulls are after a 0 in the same row. Am I missing something?

    Thank you!

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Convert to Binary

    Well, I have only checked the output and seems to the same as you had expected.

  5. #5
    Registered User
    Join Date
    10-19-2016
    Location
    New York City, New York
    MS-Off Ver
    2015
    Posts
    13

    Re: Convert to Binary

    Can you send me the total code with your code included? Maybe I'm making some dumb mistake. When I run this code, I7 through K7 populate with 0, even though they are supposed to stay null. Thank you so much for all your help!

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Convert to Binary

    This is true on

    x(i, iii) = "" And InStr(1, x(2, iii), "_") > 0

    when iii is 9 and
    then
    If x(i, ii) = x(1, iii) is false as x(I,ii) is 0 and x(1, iii) is 2- both conditions have to be true, if not, it returns 0
    I would not be able to reply until I get an internet connection.

  7. #7
    Registered User
    Join Date
    10-19-2016
    Location
    New York City, New York
    MS-Off Ver
    2015
    Posts
    13

    Re: Convert to Binary

    Ah that makes sense. Thank you for explaining. I'm not totally sure what the final code should be then to solve for this? Sorry I'm still trying to learn vba.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Convert to Binary

    I do not understand the algorithm.
    Look at rows 6 and 8 and show me what is the difference and how do you get the result?

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Convert to Binary

    I've got to ask - what exactly are you converting and what are you converting it to?
    If posting code please use code tags, see here.

  10. #10
    Registered User
    Join Date
    10-19-2016
    Location
    New York City, New York
    MS-Off Ver
    2015
    Posts
    13

    Re: Convert to Binary

    Yeah, I don't think this will work. Do you have any recommendations/ideas how to solve this? Thanks AB33

  11. #11
    Registered User
    Join Date
    10-19-2016
    Location
    New York City, New York
    MS-Off Ver
    2015
    Posts
    13

    Re: Convert to Binary

    Hi Norie, what I am trying to do is convert existing columns into binary or null. So, in the attached file in my first post, there are columns with numbers and blank columns to the right of them. The number of blank columns are equal to the max value of the column before it. I want to populate the blank columns with nulls, 0, or 1 based on the previous column with numbers. So for example, in the attachment, column A has a max value of 3, so there are currently 3 blank columns next to it. If a cell in column A is null (A4), then B4-D4 should remain null. If a cell in column A is 1 (A3), then cells B3 should change to 1 and C3-D3 should be 0. If a cell in column A is 2 (A10), then cell C10 should be 1 and B2 and D2 should be 0. And so on... The code should do this to the entire table (btw the table in the attached is just an example - the numbers/columns/rows will all change, so the code should not stop after column J or Row 13). Does this make sense? Can you see my attachment?

    I know that was a long winded answer, but I hope it makes it more clear!

    Thanks

  12. #12
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Convert to Binary

    I would do it like this :
    Please Login or Register  to view this content.
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

+ 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] Convert Binary to Octal
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-06-2015, 11:59 AM
  2. Function to convert UTF16 or binary to UTF-8
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-26-2015, 04:08 AM
  3. Convert Hex to Binary formula
    By EddieK in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-01-2012, 02:35 PM
  4. How to convert binary to date/time
    By snb in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-17-2010, 12:34 AM
  5. Convert word to binary
    By elbertvillarreal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-28-2010, 06:09 PM
  6. [SOLVED] Convert Binary to Hex
    By Chipmunk in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-30-2009, 06:02 AM
  7. [SOLVED] Convert SpreadsheetML to binary .xls
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2006, 01:50 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