research increment code

Osmarls

New Member
Joined
Jul 18, 2010
Messages
5
Hello friends, I have this code that does a search in the entire worksheet seeking value in a range of column D, I need it to check if column B there is anything typed in, if blank, even if column B contains the item searched him to jump to the next:
Private Sub PESQUISAR_Click()
Dim i As Integer
Dim PES As Variant
Dim ws As Worksheet
Dim rg As Range
PES = Application.InputBox("Informe valor a ser pesquisado.", "LABORATÓRIO LCQ.")
For Each ws In ActiveWorkbook.Worksheets

For Each rg In ws.[D1:D80]
If rg = PES Then i = i + 1
Next rg
Next ws
txtqt.Value = i ' Amount found in the research
txtname.Value = PES ' Name search
End Sub

Att

Osmarls
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hello,

Do you want to see if this code works for you. It will display in a msgbox the worsheet name and cell address, this is just to verify if the code works [at least on my side]. Let me know how it goes.

Private Sub PESQUISAR_Click()
Dim i As Integer
Dim PES As Variant
Dim ws As Worksheet
Dim rg As Range
PES = Application.InputBox("Informe valor a ser pesquisado.", "LABORATÓRIO LCQ.")
For Each ws In ActiveWorkbook.Worksheets
For Each rg In ws.[D1:D80]
If rg = PES And IsEmpty(rg.Offset(, -2)) Then
MsgBox ws.Name & " " & rg.Address
End If
Next
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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