Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Convert a number upto 100 to binary

Has anybody got a piece of code that can convert a nuber in a cell, say A1
and display it as a 7 digit binary number in B1?
I have tried to do this working from the 7th digit backwards using
combinations of 'if' and 'and' functions, but by the time I get to the 5/4
digits I am losing the will to live!

Many thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Convert a number upto 100 to binary

In be enter:

=DEC2BIN(A1) and copy down
--
Gary''s Student
gsnu200708


"Mark Dullingham" wrote:

Has anybody got a piece of code that can convert a nuber in a cell, say A1
and display it as a 7 digit binary number in B1?
I have tried to do this working from the 7th digit backwards using
combinations of 'if' and 'and' functions, but by the time I get to the 5/4
digits I am losing the will to live!

Many thanks in advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Convert a number upto 100 to binary

=DEC2BIN(A21)

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Mark Dullingham" wrote in
message ...
Has anybody got a piece of code that can convert a nuber in a cell, say A1
and display it as a 7 digit binary number in B1?
I have tried to do this working from the 7th digit backwards using
combinations of 'if' and 'and' functions, but by the time I get to the 5/4
digits I am losing the will to live!

Many thanks in advance



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Convert a number upto 100 to binary

Look at the function dec2bin in the VBA help.

RBS

"Mark Dullingham" wrote in
message ...
Has anybody got a piece of code that can convert a nuber in a cell, say A1
and display it as a 7 digit binary number in B1?
I have tried to do this working from the 7th digit backwards using
combinations of 'if' and 'and' functions, but by the time I get to the 5/4
digits I am losing the will to live!

Many thanks in advance


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Convert a number upto 100 to binary

=DEC2BIN(A1,7)
if you always want 7 binary "digits"
--
Gary''s Student
gsnu200708


"Mark Dullingham" wrote:

Has anybody got a piece of code that can convert a nuber in a cell, say A1
and display it as a 7 digit binary number in B1?
I have tried to do this working from the 7th digit backwards using
combinations of 'if' and 'and' functions, but by the time I get to the 5/4
digits I am losing the will to live!

Many thanks in advance



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Convert a number upto 100 to binary

=DEC2BIN(100,7)

Requires analysis toolpack.

--
Tim Williams
Palo Alto, CA


"Mark Dullingham" wrote in message
...
Has anybody got a piece of code that can convert a nuber in a cell, say A1
and display it as a 7 digit binary number in B1?
I have tried to do this working from the 7th digit backwards using
combinations of 'if' and 'and' functions, but by the time I get to the 5/4
digits I am losing the will to live!

Many thanks in advance



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Convert a number upto 100 to binary

WOW thanks for the quick response.

Tried this but get a #NAME? error.

Is there an add on or a definition I need to make this work?



"Gary''s Student" wrote:

In be enter:

=DEC2BIN(A1) and copy down
--
Gary''s Student
gsnu200708


"Mark Dullingham" wrote:

Has anybody got a piece of code that can convert a nuber in a cell, say A1
and display it as a 7 digit binary number in B1?
I have tried to do this working from the 7th digit backwards using
combinations of 'if' and 'and' functions, but by the time I get to the 5/4
digits I am losing the will to live!

Many thanks in advance

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Convert a number upto 100 to binary

Mark,
You need the Analysis Tool pack add-in installed.

Or you can make your own version. This seems to work:

Public Function MyDec2Bin(DecIn As Long, Optional MaxBin As Long = 7) As
String
Dim TempStr As String
Dim i As Long

Do Until Len(TempStr) = MaxBin
If (DecIn And 2 ^ i) = 2 ^ i Then
TempStr = "1" & TempStr
Else
TempStr = "0" & TempStr
End If
i = i + 1
Loop

MyDec2Bin = TempStr

End Function

NickHK

"Mark Dullingham" wrote in
message ...
WOW thanks for the quick response.

Tried this but get a #NAME? error.

Is there an add on or a definition I need to make this work?



"Gary''s Student" wrote:

In be enter:

=DEC2BIN(A1) and copy down
--
Gary''s Student
gsnu200708


"Mark Dullingham" wrote:

Has anybody got a piece of code that can convert a nuber in a cell,

say A1
and display it as a 7 digit binary number in B1?
I have tried to do this working from the 7th digit backwards using
combinations of 'if' and 'and' functions, but by the time I get to the

5/4
digits I am losing the will to live!

Many thanks in advance



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert binary to decimal Krishnakanth Excel Discussion (Misc queries) 2 May 7th 08 02:56 PM
formula to round up any number less than 35 upto 35. Bro40dz Excel Discussion (Misc queries) 5 October 26th 06 07:57 PM
decimal number convert to 16bit binary Peter Cheang[_2_] Excel Programming 2 August 31st 06 07:49 AM
Convert Binary to Hex Chipmunk Excel Programming 9 August 24th 06 12:53 PM
Convert SpreadsheetML to binary .xls [email protected] Excel Programming 0 March 17th 06 05:45 PM


All times are GMT +1. The time now is 03:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"