search by inputbox between two columns show result in two columns

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,429
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
hi,
i have 4 columns in sheet a= number of code b= the name when i search by inputbox the name it transfer the name to column c and show the number of code to column d
and when i search by inputbox the number of code it transfer the number of code to column d and show the name to column c i need adjusting my code
VBA Code:
Sub FindName()
    Dim v As String
    v = Application.InputBox(Prompt:="Enter Name:", Type:=2)
    mesage = ""
    For Each r In ActiveSheet.UsedRange
        If InStr(1, r.Value, v) > 0 Then
       
       
            mesage = mesage & r & vbCrLf
        End If
    Next
    If mesage = "" Then
        mesage = "Name not found"
    End If
    MsgBox mesage
End Sub
 

Attachments

  • gg.JPG
    gg.JPG
    26.8 KB · Views: 4

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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