Hello
Getting 2 Errors
1st one
Error BC30057 Too many arguments to 'Function CountIf(Arg1 As Range, Arg2 As Object) As Double'.
before the Build
2nd One
System.MissingMemberException: 'Public member 'WorksheetFunction' on type 'Worksheet' not found.'
This was when executing
and got hilited on the following syntax
pcSrchdRng = crFind.Resize(myExcel.WorksheetFunction.CountIf(.Range("B:B"), txtBx1.Text, 3).address(0, 0)).ToString
If not clear for above code then to inform you that wanting the Range address of TextBox.Value/Text from ExcelSheet
SamD
Thread 6: 892273
30
Getting 2 Errors
1st one
Error BC30057 Too many arguments to 'Function CountIf(Arg1 As Range, Arg2 As Object) As Double'.
before the Build
2nd One
System.MissingMemberException: 'Public member 'WorksheetFunction' on type 'Worksheet' not found.'
This was when executing
and got hilited on the following syntax
pcSrchdRng = crFind.Resize(myExcel.WorksheetFunction.CountIf(.Range("B:B"), txtBx1.Text, 3).address(0, 0)).ToString
Code:
Sub Trial()
Dim myExcel As New Microsoft.Office.Interop.Excel.Application()
Dim xlWbk As Excel.Workbook = Nothing
Dim xlWKs As Excel.Worksheet = Nothing
myExcel = New Microsoft.Office.Interop.Excel.Application
Dim strFilename As String = "C:\Trial\listData.xlsx"
xlWbk = myExcel.Workbooks.Open(strFilename)
xlWKs = CType(xlWbk.Worksheets("Sheet5"), Microsoft.Office.Interop.Excel.Worksheet)
Dim crFind As Microsoft.Office.Interop.Excel.Range = Nothing
Dim pcSrchdRng As String
With xlWKs
Dim pcFindRng As Microsoft.Office.Interop.Excel.Range = .Range("B:B")
crFind = pcFindRng.Find(txtBx1.Text,, XlFindLookIn.xlValues, XlLookAt.xlWhole, , XlSearchDirection.xlNext, False)
If Not crFind Is Nothing Then
pcSrchdRng = crFind.Resize(myExcel.WorksheetFunction.CountIf(.Range("B:B"), txtBx1.Text, 3).address(0, 0)).ToString
MessageBox.Show(pcSrchdRng)
Else
pcSrchdRng = ""
MessageBox.Show("Sorry No Range")
End If
End With
End Sub
SamD
Thread 6: 892273
30