Excel - finding values that “look like”

前端 未结 3 1697
渐次进展
渐次进展 2021-01-16 12:08

I have an excel workbook with a ton of sheets. In the first sheet \"users\" i have userdata, firstname, lastname, email, etc. all neatly split from a CSV file. In the other

3条回答
  •  遥遥无期
    2021-01-16 12:31

    The searched value can be easily found in all the workbook with the textbox and option buttons that they are added to the workbook's first sheet .

    enter image description here

    Through option buttons,value in textbox can be searched as two types , whole or part :

    If Sheets(1).OptionButton1 = True Then
    Set Firstcell = Cells.Find(What:=Sheets(1).TxtSearch, LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
    Else
    Set Firstcell = Cells.Find(What:=Sheets(1).TxtSearch, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
    End If
    

    I too have used Find & FindNext Method in template coding :

    If Not Firstcell Is Nothing Then
    Firstcell.Activate
    Firstcell.Interior.ColorIndex = 19
    
    With Sheets("New_Report").Range("A1")
    .Value = "Addresses Of The Found Results"
    .Interior.ColorIndex = 19
    End With
    Sheets("New_Report").Range("A:A").EntireColumn.AutoFit
    Sheets("New_Report").Range("A" & Rows.Count).End(xlUp).Offset(1, 0) = oSheet.Name & "!" & Firstcell.Address(False, False)
    
    Call Create_Hyperlinks  'Hyperlinks are generated in New Report Sheet
    
    If MsgBox("Found " & Chr(34) & Sheets(1).TxtSearch & Chr(34) & " in " & oSheet.Name & "!" & Firstcell.Address & vbLf & "Do You Want To Continue?", vbExclamation + vbYesNo) = vbNo Then
    Exit Sub: End If
    
    While (Not NextCell Is Nothing) And (Not NextCell.Address = Firstcell.Address)
                        counter = counter + 1
    Firstcell.Interior.ColorIndex = xlNone
    Set NextCell = Cells.FindNext(After:=ActiveCell)
    
    If NextCell.Row = 2 Then
    Set NextCell = Range(Cells(3, 1), Cells(Cells(Rows.Count, 1).End(xlUp).Row, LastColumn)).FindNext(After:=ActiveCell)
    End If
    
    If Not NextCell.Address = Firstcell.Address Then
    NextCell.Activate
    NextCell.Interior.ColorIndex = 19
    Sheets("New_Report").Range("A" & Rows.Count).End(xlUp).Offset(1, 0) = oSheet.Name & "!" & NextCell.Address(False, False)
    
    Call Create_Hyperlinks
    
    If MsgBox("Found " & Chr(34) & Sheets(1).TxtSearch & Chr(34) & " in " & oSheet.Name & "!" & NextCell.Address & vbLf & "Do You Want To Continue?", vbExclamation + vbYesNo) = vbNo Then
    Exit Sub: End If
    
    End If 'If Not NextCell.Address = Firstcell.Address Then
    NextCell.Interior.ColorIndex = xlNone
    
    Wend
    End If
    Next oSheet
    End If
    

    All results are listed as hyperlinks in the generated report sheet with different a function.

提交回复
热议问题