Ich erhalte einen Typenkonflikt beim Durchsuchen einer Zelle für einen Zeitraum "." oder "p". Es funktionierte, als ich nur das "." aber nach dem Hinzufügen von "p" bekomme ich eine Typabweichung. Ist eine Variant/Empty für my_txt nur in der Lage, Ganzzahlen und "." S zu verwenden? Ich versuche, meinen Filter zu verwenden, um den Umrisslevel zu bestimmen.Typenkonflikt bei der Codesuche innerhalb einer Zelle
Sub ProcessDocV5()
Dim Level As Range
Dim i, j, q(1 To 50) As Long
Dim numofchar As Long
Dim filepath As String
Dim filename As String
Dim LastRow As Long
Dim rowcallout As Long
Dim columncallout As Long
'scanf(Input the correct row and column numbers).
rowcallout = InputBox("LOCATION ROW OF HEADERS?")
columncallout = InputBox("LOCATION COLUMN OUTLINE? (A=1, B=2, ect...)")
Debug.Print "rowcallout value is "; [rowcallout]
Debug.Print "columncallout value is "; [columncallout]
'END OF SCAN
'ADJUST EXCEL SCREEN
'stop screen updating
Application.ScreenUpdating = False
'show gridlines
ActiveWindow.DisplayGridlines = True
'remove borders
ActiveWindow.DisplayGridlines = True
Cells.Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
'group according to level column (Cell(row,column))
Set Level = Range(Cells(rowcallout, columncallout), Cells(873, 2))
Debug.Print "The value of Levels is "; Level.Address
For i = rowcallout To Level.count
Cells(i, columncallout).Select
a = Len(Cells(i, columncallout))
Debug.Print "A value is "; [a]
my_txt = Replace(Cells(i, columncallout), "." Or "p", "", 1, -1, vbTextCompare)
b = Len(my_txt)
Debug.Print "B value is "; [b]
numb_occur = a - b + 1
Debug.Print [numb_occur]
If numb_occur < 8 Then
Rows(i).OutlineLevel = numb_occur - 1
Else
Rows(i).OutlineLevel = 8
End If
Next i
With ActiveSheet.Outline
.AutomaticStyles = False
.SummaryRow = xlAbove
.SummaryColumn = xlRight
End With
'Close tabs for neatness
ActiveSheet.Outline.ShowLevels RowLevels:=8
ActiveSheet.Outline.ShowLevels RowLevels:=7
ActiveSheet.Outline.ShowLevels RowLevels:=6
ActiveSheet.Outline.ShowLevels RowLevels:=5
ActiveSheet.Outline.ShowLevels RowLevels:=4
ActiveSheet.Outline.ShowLevels RowLevels:=3
ActiveSheet.Outline.ShowLevels RowLevels:=2
ActiveSheet.Outline.ShowLevels RowLevels:=1
End Sub