?
Solved

Md5 checksum in excel (vba)

Posted on 2011-09-15
6
Medium Priority
?
13,010 Views
Last Modified: 2012-06-27
Hi,

I searched and found a solution that almost made my day :)
http:/Q_23395844.html

The problem I have is that some strings that I want to create checksums on are more than 255 characters and than I get a #VALUE returned.

I want to create a checksum for each row in my sheet, so I have a formula similar to this: =md5hash(concatenate(C4;D4;E4;F4 ...).

Thankful for all help.

Now attached a file for your reference:
md5-testing.xls

Regards, Tobias Gårdner
0
Comment
Question by:tobiasgardner
  • 4
  • 2
6 Comments
 

Author Comment

by:tobiasgardner
ID: 36547703
One answer to my own question after some more browsing...
There is a problem to pass strings as in the example, but if the value is concatenated in a separate cell before passed to the md5hash function, it will work....
In new attached example, the string is concatenate in E6 and the md5hash is calculated in D6 with reference to E6 and this works!
md5-testing.xls

Perhaps there are other solutions and if someone has one, I am interested :)

Regards,
Tobbe G
0
 
LVL 46

Accepted Solution

by:
aikimark earned 2000 total points
ID: 36552857
If you create your own concatenation routine, such as BigConcat()

Public Function BigConcat(parmRange As Range) As String
    Dim rngCell As Range
    Dim strConcat As String
    For Each rngCell In parmRange
        strConcat = strConcat & rngCell.Value
    Next
    BigConcat = strConcat
End Function

Open in new window


You would be able to do something like this:
=md5hash(BigConcat(I4:Q4))

Open in new window


Note: this routine, as written, only handles a single contiguous range.  You would put this in Module1 in your project.
0
 

Author Comment

by:tobiasgardner
ID: 36558220
Thanks I will keep that under good to have. In this case I can not use contiguous range.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 46

Expert Comment

by:aikimark
ID: 36567417
@tobiasgardner

>>I can not use contiguous range
you use some contiguous ranges in the workbook you posted and in your question text.  You can use the BigConcat() function to coalesce such ranges in your CONCATENATE() call.  If you encounter character limits, you can rename the BigConcat() function as BC().

The BigConcat() can be tweaked to accept more ranges (as parameters).  It would then behave like the CONCATENATE() function.
0
 
LVL 46

Expert Comment

by:aikimark
ID: 36568655
This version of BigConcat accepts a range that may have multiple areas.  This must be enclosed in parenthesis.

Example:
This formula would return the concatenated values from the 4th, 6th, and 8th rows from your F:Q data columns.
=BCA((F4:Q4,F6:Q6,F8:Q8))

Open in new window


You could feed the results of the BCA() function into your MD5 hashing function:
=md5hash(BCA((F4:Q4,F6:Q6,F8:Q8)))

Open in new window


Public Function BCA(parmRangeAreas As Range, Optional parmDelim As String) As String
    'BCA is a Big Concatenation of Areas function
    'pass a parenthesis enclosed range area and the BCA function will concatenate the values in all cells.
    'The optional parameter, parmDelim allows you to add a delimiter string between the concatenated cell values.
    Dim rngArea As Range
    Dim rngCell As Range
    Dim strConcat As String
    Dim strDelim As String
    For Each rngArea In parmRangeAreas.Areas
        For Each rngCell In rngArea
            strConcat = strConcat & strDelim & rngCell.Value
            strDelim = parmDelim
        Next
    Next
    BCA = strConcat
End Function

Open in new window

0
 
LVL 46

Expert Comment

by:aikimark
ID: 37007587
The Better Concatenate Function (BCF) article has just been published.
http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html

The BCF is immune from performance problems you might encounter with large concatenation operations and allows you to automatically insert a delimiter string.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

New style of hardware planning for Microsoft Exchange server.
MS Outlook undoubtedly is the most widely used email client.Its user-friendliness, cost effectiveness, and availability with Microsoft Office Suite make it the most popular email application.  Its compatibility with Microsoft applications like Exch…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question