DPlot

Author Message
Phillip Mathis

Joined: 10 Dec 2009
Posts: 20

 Posted: Tue Jul 08, 2014 10:21 am    Post subject: Excel Conversion 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.

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

 Posted: Tue Jul 08, 2014 11:54 am    Post subject: 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
Phillip Mathis

Joined: 10 Dec 2009
Posts: 20

 Posted: Thu Jul 10, 2014 9:05 am    Post subject: Thanks David, the WorksheetFunction is what I was missing.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT - 5 Hours Page 1 of 1