Solved

Md5 checksum in excel (vba)

Posted on 2011-09-15
6
10,913 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 45

Accepted Solution

by:
aikimark earned 500 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 45

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 45

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 45

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Have you ever had the experience that you had to follow 10 steps over and over again every time when you need to nicely forward an important email to your manager? Fear no more! With the help of the Quick Steps feature in Outlook 2010, your old chor…
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now