Searching for octet data in a range

Campbell Botting

New Member
Joined
Jun 9, 2015
Messages
7
I am running the following code to find the first entry in a sheet. Works OK for the general data but not the second call which is searching for a named IP address. It comes up with an "Object variable or With Block Variable not set" error
Code:
Code:
Sub Find()
'
' Find Macro
'


'
    Range("A2").Select
    
    'Find asset name on CCL Manage report and get IP number
    findcolumn = "A:A"
    searchdata = ActiveCell.Value
    searchsheet = "CCLManage Report"
    Call findentry(searchdata, findcolumn, searchsheet)
    ipnumber = ActiveCell.Offset(0, 7).Value
    
    'find ip number on splunk report
    findcolumn = "D:D"
    searchdata = ipnumber
    searchsheet = "splunk_12-6-2015"
    Call findentry(searchdata, findcolumn, searchsheet)
    
    
    
End Sub
Sub findentry(searchdata, findcolumn, searchsheet)


    ActiveWorkbook.Sheets(searchsheet).Activate
    Range(findcolumn).Select
       
    
    'find entry
    Selection.Find(What:=searchdata, After:=ActiveCell, LookIn:=xlValues _
        , LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate


End Sub
 
Last edited by a moderator:

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Data columns working with are. I am trying to find out how many times each user has used the IP address. ie LibbyK = 8 MCoote = 3

LibbyK10.0.21.97
LibbyK10.0.21.97
LibbyK10.0.21.97
LibbyK10.0.21.97
LibbyK10.0.21.97
LibbyK10.0.21.97
LibbyK10.0.21.97
LibbyK10.0.21.97
MCoote10.0.21.97
MCoote10.0.21.97
MCoote10.0.21.97
 
Upvote 0
What happens if it cannot find the value you are looking for?
That may be what is causing the error. In that case, you will need to add in some error handling.
An easy way to tell is to step through your code line-by-line using the F8 key and see where it errors out.

If you have two monitors, you can have the code on one side, and your sheet on the other, so you can see/watch what the code is doing on the sheet while you are stepping through it. Otherwise, just resize the VB Editor so that it is small enough that you can see both.
 
Upvote 0
:pHave found the answer. I was stepping through and it was the second pass of the selection find statement. The find statement does not work well with a table as it searches the table reference rather than the data contained within. Once I copied the data values to another column and searched on that no problem. Appreciate your input though. Thanks
 
Upvote 0

Forum statistics

Threads
1,203,094
Messages
6,053,506
Members
444,667
Latest member
KWR21

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