K
KeLee
Hello MVP's
An initial Caveat, I know almost nothing about VBA
I have, laboriously, created this code to check validation in my workbook
and highlight any cells in certain ranges that conflict with the allowed
validation.
I want to do this as i have an automated routine that pastes values into
these ranges from my CRM software, which can override the validation rules
set for manual entry - this is fine as I just then need users to update a few
conflicts.
So far I have this
Sub SetInvalidCellsRedAndStore()
Dim CACompiler(540) As String
Dim SheetCompiler(540) As String
ArrayCell = 0
For Each Sheet In Sheets
Sheet.Activate
Calculate
For Each Cell In Range("D10:E29")
ArrayCell = ArrayCell + 1
If Cell.Validation.Value = False Then
Cell.Interior.ColorIndex = 3
Cell.Font.Bold = True
CACompiler(ArrayCell) = Cell.Address
SheetCompiler(ArrayCell) = Sheet.Name
Else:
End If
Next Cell
Next Sheet
End Sub
Which at the end gives me two arrays each 540 items long with values in if
the corresponding cell matched the criteria i.e. failed validation checks.
all the other entries will be blank, that is not ideal, but OK.
All I want to do now is paste the contents of those two arrays into another
sheet.
I want the values of "SheetCompiler" to go into a sheet called "Datastore"
in the range A2:A541
And similarly, the values of "CACompiler" to go into the same sheet,
"Datastore" in the range B2:B541
But I can't even get close to getting it right despite having looked up
about 20 examples. I couldn't figure out how to customise them to my
requirements.
Any help with this is most appreciated.
Regards,
KeLee
An initial Caveat, I know almost nothing about VBA
I have, laboriously, created this code to check validation in my workbook
and highlight any cells in certain ranges that conflict with the allowed
validation.
I want to do this as i have an automated routine that pastes values into
these ranges from my CRM software, which can override the validation rules
set for manual entry - this is fine as I just then need users to update a few
conflicts.
So far I have this
Sub SetInvalidCellsRedAndStore()
Dim CACompiler(540) As String
Dim SheetCompiler(540) As String
ArrayCell = 0
For Each Sheet In Sheets
Sheet.Activate
Calculate
For Each Cell In Range("D10:E29")
ArrayCell = ArrayCell + 1
If Cell.Validation.Value = False Then
Cell.Interior.ColorIndex = 3
Cell.Font.Bold = True
CACompiler(ArrayCell) = Cell.Address
SheetCompiler(ArrayCell) = Sheet.Name
Else:
End If
Next Cell
Next Sheet
End Sub
Which at the end gives me two arrays each 540 items long with values in if
the corresponding cell matched the criteria i.e. failed validation checks.
all the other entries will be blank, that is not ideal, but OK.
All I want to do now is paste the contents of those two arrays into another
sheet.
I want the values of "SheetCompiler" to go into a sheet called "Datastore"
in the range A2:A541
And similarly, the values of "CACompiler" to go into the same sheet,
"Datastore" in the range B2:B541
But I can't even get close to getting it right despite having looked up
about 20 examples. I couldn't figure out how to customise them to my
requirements.
Any help with this is most appreciated.
Regards,
KeLee