PC Review


Reply
Thread Tools Rate Thread

Convert a number upto 100 to binary

 
 
=?Utf-8?B?TWFyayBEdWxsaW5naGFt?=
Guest
Posts: n/a
 
      26th Feb 2007
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 With Quote
 
 
 
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      26th Feb 2007
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 With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      26th Feb 2007
=DEC2BIN(A21)

--
---
HTH

Bob

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



"Mark Dullingham" <(E-Mail Removed)> wrote in
message news:F7FFE808-11BB-442A-849A-(E-Mail Removed)...
> 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 With Quote
 
RB Smissaert
Guest
Posts: n/a
 
      26th Feb 2007
Look at the function dec2bin in the VBA help.

RBS

"Mark Dullingham" <(E-Mail Removed)> wrote in
message news:F7FFE808-11BB-442A-849A-(E-Mail Removed)...
> 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 With Quote
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      26th Feb 2007
=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

 
Reply With Quote
 
Tim Williams
Guest
Posts: n/a
 
      26th Feb 2007
=DEC2BIN(100,7)

Requires analysis toolpack.

--
Tim Williams
Palo Alto, CA


"Mark Dullingham" <(E-Mail Removed)> wrote in message
news:F7FFE808-11BB-442A-849A-(E-Mail Removed)...
> 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 With Quote
 
=?Utf-8?B?TWFyayBEdWxsaW5naGFt?=
Guest
Posts: n/a
 
      26th Feb 2007
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 With Quote
 
NickHK
Guest
Posts: n/a
 
      27th Feb 2007
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" <(E-Mail Removed)> wrote in
message news:BE2D6A2D-4080-4EDD-B31E-(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
formula to round up any number less than 35 upto 35. =?Utf-8?B?QnJvNDBkeg==?= Microsoft Excel Misc 5 26th Oct 2006 07:57 PM
decimal number convert to 16bit binary =?Utf-8?B?UGV0ZXIgQ2hlYW5n?= Microsoft Excel Programming 2 31st Aug 2006 07:49 AM
Convert file to binary, send it over the network, and convert it b =?Utf-8?B?Q2hld2ll?= Microsoft Dot NET 0 9th Sep 2005 06:04 PM
Convert file to binary, send it over the network, and convert it b =?Utf-8?B?Q2hld2ll?= Microsoft Dot NET Framework 1 9th Sep 2005 06:01 PM
Convert String to Binary number or other recognizable repersentation pei_world Microsoft C# .NET 1 31st Mar 2004 10:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:09 AM.