ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA dropdownlist to put in cell's comment creates runtime error whenthe dropdownlist is above 266 lines (https://www.excelbanter.com/excel-programming/449459-vba-dropdownlist-put-cells-comment-creates-runtime-error-whenthe-dropdownlist-above-266-lines.html)

Denisetoo

VBA dropdownlist to put in cell's comment creates runtime error whenthe dropdownlist is above 266 lines
 
I get a run time "1004" when the comment lines are at 266 lines. WIth less than 200 comment lines the code runs fine. The DropDownTmp variable list includes all 266 lines. The comment field cuts off around 253 lines of code. The program stops with the run time error.

Any ideas on how to fix this?

SearchRowTemp = SearchRow
ErrorDesc = Sheets(SNLogNew).Cells(LogRowCounter, 1).Value & Sheets(SNLogNew).Cells(LogRowCounter, 2).Value
Do Until ErrorDesc = ""

If Left(ErrorDesc, 3) = " " Or Sheets(SNLogNew).Cells(LogRowCounter, 1).Value = "" Then
' Add a comment
If Not Found Then
If NewComment Then
Sheets(SNTD).Cells(TDRowCounter - 1, Tdf_Col_Error).AddComment Text:=Trim(ErrorDesc)
Sheets(SNTD).Cells(TDRowCounter - 1, Tdf_Col_Error).Comment..Shape.TextFrame.AutoSize = True
NewComment = False
Else
Sheets(SNTD).Cells(TDRowCounter - 1, Tdf_Col_Error).Comment..Text Text:=Sheets(SNTD).Cells(TDRowCounter - 1, Tdf_Col_Error).Comment.Text & Chr(10) & Trim(ErrorDesc)
End If
' Determine the number of specs in the drop down list
i_number_comments = Len(Sheets(SNTD).Cells(TDRowCounter - 1, Tdf_Col_Error).Comment.Text) - Len(Replace(Sheets(SNTD).Cells(TDRowCounter _
- 1, Tdf_Col_Error).Comment.Text, Chr(10), ""))
Debug.Print i_number_comments
' If this is the last entry of a comment... add the data validation
If Left(ErrorDesc, 3) = " " And _
(Sheets(SNLogNew).Cells(LogRowCounter + 1, 1).Value = "" Or Left(Sheets(SNLogNew).Cells(LogRowCounter + 1, 1).Value, 3) < " ") And _
CMD_Tmp.DetailDropDown And TDRowCounter TDRow And i_number_comments 250 Then


DropDownTmp = Sheets(SNTD).Cells(TDRowCounter - 1, Tdf_Col_Error).Comment.Text
' Add Drop Down Selection for "Detail" Cell
With Sheets(SNTD).Cells(TDRowCounter - 1, Tdf_Col_Detail).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=DropDownTmp
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.IMEMode = xlIMEModeNoControl
.ShowInput = True
.ShowError = True
End With

End If

End IfShow trimmed content


All times are GMT +1. The time now is 12:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com