-1
我在單元格中搜索句號時出現類型不匹配「。」或「p」。當我只使用「。」時它有效。但添加「p」後,我得到一個類型不匹配。 my_txt的Variant/Empty是否只能使用整數和「。」s?我試圖讓我的過濾器使用。's或p來確定大綱級別。單元格內代碼搜索類型不匹配
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