DPlot Forum Index DPlot
http://www.dplot.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Excel Conversion

 
Post new topic   Reply to topic    DPlot Forum Index -> Excel
View previous topic :: View next topic  
Author Message
Phillip Mathis



Joined: 10 Dec 2009
Posts: 20

PostPosted: Tue Jul 08, 2014 10:21 am    Post subject: Excel Conversion Reply with quote

I have a question about unit conversions. First, I have data which is recorded in hex and I'm tying to convert it to binary. If the hex number is numerical, excel treats it as an integer (1840). If it contains a letter (C08A) excel treats it as text. So I'm trying to create code that will find the first value (MSB); C in the example above. Then convert this value to binary and then move to the next hex value. After conversion, I need to reassemble these values from MSB to LSB.

Your assistance would be greatly appreciated.
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2290
Location: Vicksburg, Mississippi

PostPosted: Tue Jul 08, 2014 11:54 am    Post subject: Reply with quote

On the spreadsheet you can use HEX2DEC, as in
=HEX2DEC(A1) (if your hex value is in cell A1)

and
=INT(B1/256)+256*MOD(B1,256)
to byte-swap, assuming your converted decimal value is in B1.

A nice feature about HEX2DEC is it doesn't assume anything about your input: HEX2DEC(1840) will treat 1840 as a hexadecimal value even though it shows as a normal decimal number on your sheet.

In VBA you just need to add WorksheetFunction, as in:

Cells(1,2) = WorksheetFunction.Hex2Dec(Cells(1,1))
_________________
David Hyde
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Phillip Mathis



Joined: 10 Dec 2009
Posts: 20

PostPosted: Thu Jul 10, 2014 9:05 am    Post subject: Reply with quote

Thanks David, the WorksheetFunction is what I was missing.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    DPlot Forum Index -> Excel All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group