Results 1 to 8 of 8

Thread: colums to rows

  1. #1
    Join Date
    Mar 2004
    Posts
    69

    Unanswered: 2's complement

    I've got a excel file which has three rows the first being the heading for each colum and the other two are my data recipe 1 & recipe 2. I have over 100 colums of ingredients for the recipes. All i want to do is turn the spread sheet 90 degrees so that I then have three colums and all my ingredients are in the row's so I can print the ting out beter. I'm not sure what the correct term is for this procedure so I havent had any luck in help menu.
    Last edited by ISLMAN1975; 11-26-04 at 09:00.

  2. #2
    Join Date
    Nov 2004
    Posts
    13
    The term is "Transpose".
    You would need to copy and paste your entire range including column headers. But to paste you must first right click to activate Excel's short menu. Then select "Paste Special" and click "Transpose". Hope this helps.

  3. #3
    Join Date
    Mar 2004
    Posts
    69
    Simple when you know how. Thanks thats worked a treat.

    Here's another one for anybody is there a function to find the 2's complement of a number. I've tried inverting it using NOT and then I was going to add 1 but the NOT expression just returns true or false I want it to invert all the bit and give me a decimal value.

    Quote Originally Posted by cdistefano
    The term is "Transpose".
    You would need to copy and paste your entire range including column headers. But to paste you must first right click to activate Excel's short menu. Then select "Paste Special" and click "Transpose". Hope this helps.

  4. #4
    Join Date
    Jan 2004
    Location
    Aberdeen, Scotland
    Posts
    1,067
    can you let me know what the 2's complement is and ill try and help you out

    Dave

  5. #5
    Join Date
    Mar 2004
    Posts
    69
    375321.7208

  6. #6
    Join Date
    Jan 2004
    Location
    Aberdeen, Scotland
    Posts
    1,067
    erm okay im none the wiser, is there a logical process to go through to obtain the 2's complement,

    i.e. 1/X + 1 where X <> 0 etc.

    Dave

  7. #7
    Join Date
    Mar 2004
    Posts
    69
    I want the 2'complement of this number 375322

  8. #8
    Join Date
    Jan 2004
    Location
    Aberdeen, Scotland
    Posts
    1,067
    Ok ive written a function for you this only returns the value of the 2's Comlement as a string, the function reads in binary and outputs a string in binary format


    Code:
    Function TwosComplement(ByVal rngNum As Range) As String
    'written by David Coutts
    '26/11/2004
        
        Dim outVal As String
        Dim i As Integer, lenOrig As Integer
        Dim myNum As Long
        
        
        'Invert the Binary
        For i = 1 To Len(rngNum.Value)
            outVal = outVal & Abs((CInt(Mid(rngNum.Value, i, 1)) - 1) Mod 2)
        Next i
        
        Dim bolDone As Boolean
        'convert from binary to integer
        For i = Len(outVal) To 1 Step -1
            myNum = myNum + CInt(Mid(outVal, i, 1)) * 2 ^ (Len(outVal) - i)
        Next i
        myNum = myNum + 1
            
        'convert back to binary
        For i = Len(outVal) - 1 To 0 Step -1
            If myNum - (2 ^ i) >= 0 Then
                myNum = myNum - (2 ^ i)
                TwosComplement = TwosComplement & "1"
            Else
                TwosComplement = TwosComplement & "0"
            End If
        Next i
    
    End Function
    Dave
    Last edited by DavidCoutts; 11-26-04 at 11:23.

Posting Permissions

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