XLA routines: EE_HeadersCorrect

Often others deliver files to an application that need to have fixed col headers. Unfortunately, they often change them without telling you. This function checks that the headers are as expected before you proceed.
Function EE_HeadersCorrect(CorrectheaderRange As range, InputHeaderRange As range) As Boolean '- checks that the headers are the same in a source file vs what's expected.. '- ranges can be passed in as columns or rows '- functionally, it's just a simple For Each comparison Dim arrCorrectheaderRange As Variant Dim arrInputHeaderRange As Variant 'http://excelexperts.com/xla-routines-eeHeadersCorrect If CorrectheaderRange.Cells.Count = 1 And InputHeaderRange.Cells.Count = 1 Then EE_HeadersCorrect = (CorrectheaderRange.value = InputHeaderRange.value) ElseIf CorrectheaderRange.Cells.Count <> InputHeaderRange.Cells.Count Then EE_HeadersCorrect = False Else arrCorrectheaderRange = CorrectheaderRange arrInputHeaderRange = InputHeaderRange If CorrectheaderRange.Columns.Count > 1 Then arrCorrectheaderRange = Application.Transpose(Application.Transpose(arrCorrectheaderRange)) Else arrCorrectheaderRange = Application.Transpose(arrCorrectheaderRange) End If If InputHeaderRange.Columns.Count > 1 Then arrInputHeaderRange = Application.Transpose(Application.Transpose(arrInputHeaderRange)) Else arrInputHeaderRange = Application.Transpose(arrInputHeaderRange) End If EE_HeadersCorrect = (Join(arrInputHeaderRange, ",") = Join(arrCorrectheaderRange, ",")) Erase arrCorrectheaderRange Erase arrInputHeaderRange End If End Function
»
- Nick's blog
- Login or register to post comments
- 2851 reads
Recent comments
5 years 50 weeks ago
6 years 36 weeks ago
6 years 47 weeks ago
6 years 50 weeks ago
6 years 51 weeks ago
7 years 5 weeks ago
7 years 13 weeks ago
7 years 13 weeks ago
7 years 13 weeks ago
7 years 13 weeks ago