?
Solved

Md5 checksum in excel (vba)

Posted on 2011-09-15
6
Medium Priority
?
12,427 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

765 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