I need to update a large number of workbooks, and do this using VBA.
One of the updates is to add data validation to a given cell.
I have recorded a macro, which I am then trying to use, but I keep getting a 'Runtime error 1004 Application-defined or object-defined error'.
The recorded macro is as follows (I am using a Danish version of Excel, so the formula is with Danish functions):
I suspect that the problem is the Danish functions, since I assume that VBA needs the English versions(?)
I have, therefore, tried replacing the formula with:
"=OFFSET(INDIRECT(HLOOKUP($D7;hovedmaterielmatrix;2;FALSE));0;0;COUNTIF(INDIRECT(HLOOKUP($D7;hovedmaterielmatrix;2;FALSE)&""Col"");""?*"")-2;1)"
But with the same result.
One of the updates is to add data validation to a given cell.
I have recorded a macro, which I am then trying to use, but I keep getting a 'Runtime error 1004 Application-defined or object-defined error'.
The recorded macro is as follows (I am using a Danish version of Excel, so the formula is with Danish functions):
Code:
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:= _
"=FORSKYDNING(INDIREKTE(VOPSLAG($D7;hovedmaterielmatrix;2;FALSK));0;0;TÆL.HVIS(INDIREKTE(VOPSLAG($D7;hovedmaterielmatrix;2;FALSK)&""Col"");""?*"")-2;1)"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
I suspect that the problem is the Danish functions, since I assume that VBA needs the English versions(?)
I have, therefore, tried replacing the formula with:
"=OFFSET(INDIRECT(HLOOKUP($D7;hovedmaterielmatrix;2;FALSE));0;0;COUNTIF(INDIRECT(HLOOKUP($D7;hovedmaterielmatrix;2;FALSE)&""Col"");""?*"")-2;1)"
But with the same result.