unable to get match property of worksheetfunction class

Girish2103

New Member
Joined
Sep 28, 2021
Messages
2
Office Version
  1. 2013
Platform
  1. Windows
Here is the the code plz check

VBA Code:
Sub SearchData()

    Application.ScreenUpdating = False
   
    Dim shDatabase As Worksheet ' Database sheet
    Dim shSearchData As Worksheet 'SearchData sheet
   
    Dim iColumn As Integer 'To hold the selected column number in Database sheet
    Dim iDatabaseRow As Long 'To store the last non-blank row number available in Database sheet
    Dim iSearchRow As Long 'To hold the last non-blank row number available in SearachData sheet
   
    Dim sColumn As String 'To store the column selection
    Dim sValue As String 'To hold the search text value
   
   
    Set shDatabase = ThisWorkbook.Sheets("Database")
    Set shSearchData = ThisWorkbook.Sheets("SearchData")
   
   
    iDatabaseRow = ThisWorkbook.Sheets("Database").Range("A" & Application.Rows.Count).End(xlUp).Row
      
    sColumn = frmForm.cmbSearchColumn.Value
   
    sValue = frmForm.txtSearch.Value
   
    iColumn = Application.WorksheetFunction.Match(sColumn, shDatabase.Range("A1:I1"), 0)
   
   
   
       
    'Remove filter from Database worksheet
   
    If shDatabase.FilterMode = True Then
   
        shDatabase.AutoFilterMode = False
   
    End If

    'Apply filter on Database worksheet
   
    If frmForm.cmbSearchColumn.Value = "House No" Then
   
        shDatabase.Range("A1:I" & iDatabaseRow).AutoFilter Field:=iColumn, Criteria1:=sValue
   
    Else
   
        shDatabase.Range("A1:I" & iDatabaseRow).AutoFilter Field:=iColumn, Criteria1:="*" & sValue & "*"
   
   
    End If
   
    If Application.WorksheetFunction.Subtotal(3, shDatabase.Range("C:C")) >= 2 Then
   
        'Code to remove the previous data from SearchData worksheet
       
        shSearchData.Cells.Clear
       
        shDatabase.AutoFilter.Range.Copy shSearchData.Range("A1")
       
        Application.CutCopyMode = False
       
        iSearchRow = shSearchData.Range("A" & Application.Rows.Count).End(xlUp).Row
       
        frmForm.lstDatabase.ColumnCount = 10
       
        frmForm.lstDatabase.ColumnWidths = "30,60,75,75,75,75,75,75,75,70,70"
       
        If iSearchRow > 1 Then
       
            frmForm.lstDatabase.RowSource = "SearchData!A2:I" & iSearchRow
           
            MsgBox "Records found."
       
        End If
       
       
    Else
   
       MsgBox "No record found."
   
    End If

    shDatabase.AutoFilterMode = False
    Application.ScreenUpdating = True


End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
The error means that the value you were looking for wasn't found. What type of data is it - numeric?
 
Upvote 0
Then try:

Code:
iColumn = Application.WorksheetFunction.Match(CLng(sColumn), shDatabase.Range("A1:I1"), 0)
 
Upvote 0
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: unable to get match property of worksheetfunction class
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,223,577
Messages
6,173,163
Members
452,503
Latest member
AM74

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top