Below is the code which i gave written to search for the comment in the excel worksheet, the comments contains special characters too. can anyone help me to get rid of the type mismatch error. Below it the code which i am pasting for the reference
Option Explicit
Sub Match_ProjCode()
Dim CSAT_Comments As Workbook
Dim comment As Worksheet
Dim matchcomment As Worksheet
Dim comment_string As String 'To store the comment
Dim Column As Integer
Dim Row As Integer
Dim match_Row As Integer
Dim comments_Column_Name As String '
Dim Comments_Column_Value As String
Dim Comments_ProjCode As String 'To store the project code
Dim RangeObj As Range
Set CSAT_Comments = ActiveWorkbook
Set comment = CSAT_Comments.Worksheets("Qualitative Analysis_2018 Cycle") '
Set matchcomment = CSAT_Comments.Worksheets("Consolidated Comments") '
Dim range1 As Range
Dim rng As Range
matchcomment.Range("A2").Select
Set range1 = matchcomment.Range(Selection, Selection.End(xlDown))
For Each rng In range1.SpecialCells(xlCellTypeVisible)
comment_string = rng.Value ' Comment text will be stored
match_Row = rng.Row 'comment row will be stored
With comment
.Activate
Columns("AK:BL").Select
Set RangeObj = Selection.Find(What:=comment_string, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False) ' to search for the comment in the comment worksheet
If Not RangeObj Is Nothing Then
.Range(RangeObj.Address).Select 'Select the cell of the searched value
Column = ActiveCell.Column 'Get the column number of the searched value
Row = ActiveCell.Row ' Get the row number of the searched value
comments_Column_Name = Split(Cells(, Column).Address, "$")(1) ' Trim the column name from the cell address
Comments_Column_Value = .Range("" & comments_Column_Name & 1) ' Get the comment heading
Comments_ProjCode = .Range("A" & Row) 'Get the project code
With matchcomment
.Activate
.Range("C" & match_Row) = Comments_Column_Value ' Paste the comment heading name in the match sheet
.Range("D" & match_Row) = Comments_ProjCode 'Paste the project code in the match sheet
End With
Else
End If
End With
Next rng
End Sub