-
Jun 16th, 2021, 08:50 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Get 2 errors Error 1-BC30057 Too many arguments & 2-System.MissingMemberException:
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
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
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
Last edited by SamDsouza; Jun 16th, 2021 at 08:53 AM.
-
Jun 16th, 2021, 11:31 AM
#2
Re: Get 2 errors Error 1-BC30057 Too many arguments & 2-System.MissingMemberException
The first one seems straightforward:
1st one
Error BC30057 Too many arguments to 'Function CountIf(Arg1 As Range, Arg2 As Object) As Double'.
before the Build
Look at what the function expects and what you are sending. They should match.
Please remember next time...elections matter!
-
Jun 17th, 2021, 12:05 AM
#3
Thread Starter
Addicted Member
Re: Get 2 errors Error 1-BC30057 Too many arguments & 2-System.MissingMemberException
TysonLPrice
Look at what the function expects and what you are sending. They should match.
Thanks for pointing it out.
Just a matter of ) marked in RED
pcSrchdRng = crFind.Resize(myExcel.WorksheetFunction.CountIf(.Range("B:B"), txtBx1.Text), 3).address(0, 0)).ToString
Got Rid of both the errors
SamD
Thread 6: 892273
32
-
Jun 17th, 2021, 05:35 AM
#4
Re: [RESOLVED] Get 2 errors Error 1-BC30057 Too many arguments & 2-System.MissingMemb
At the top right of the screen is a drop down called "Thread Tools" and it has an option to mark this thread "Resolved". That helps people not look at items that do not need attention.
Please remember next time...elections matter!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|