I have a code which is working fine but it has corrupted the file i do not know why this thing is happening. I have attached a sample workbook.
If you could please help me to fix this i will appreciated the help.
Code
Dim sheet As Worksheet
Dim RangeArray As Variant
Dim i As Long
Dim d As Object
Set sheet = Worksheets("Sheet1")
With sheet
RangeArray = .Range("A2:A50000").Value
End With
Set d = CreateObject("Scripting.Dictionary")
For i = LBound(RangeArray) To UBound(RangeArray)
d(RangeArray(i, 1)) = 1
Next i
With Worksheets("Sheet2").Range("C2").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:=Join(d.Keys, ",")
.InCellDropdown = True
End With
Display More
“We found a problem with some content in ‘filename.xlsx’. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes. then i add in immediate window this and press enter and this "? application.StartupPath" appear expected : line number or label or statement or end of statement