VBA - Find value and select row with active data

Uzeal

New Member
Joined
Jun 5, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello!

I'm hoping someone can help me out here. Please let me know if this should go in the Access forum instead, but my code is opening an excel spreadsheet and manipulating the data in excel so I hope I'm okay with posting this here.

What I'm trying to do is find a value in an excel spreadsheet (the value should always exist) and select the row that has active data in it (not the entire row). I have the find portion working, I just can't figure out how to only select the row that has active data in it. This is my code and I need to replace the "ActiveCell.EntireRow.Select" with my request.

VBA Code:
 Set wks = objexcelapp.ActiveSheet
        With wks
          .Columns("E:E").Select
          Selection.Find(What:="5049923", After:=ActiveCell, LookIn:=xlValues, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
        ActiveCell.EntireRow.Select
        End With

Thank you for your help!!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Also, if it makes it easier, I just need to select columns A:K of the active row.
 
Upvote 0
Try the code below (untested)...

Code:
    Dim myRng As Range
    Set wks = objexcelapp.ActiveSheet
    With wks
        Set myRng = .Columns("E:E").Find(What:="5049923", LookIn:=xlValues, _
                    LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext)
        If Not myRng Is Nothing Then myRng.Offset(, -4).Resize(, 11).Select
    End With
 
Upvote 0
THANK YOU. The resize was off by a few columns but that was exactly what I was looking for. THANK YOU!!!
 
Upvote 0
The resize was off by a few columns

That was because I had it in my mind that it was column H not K (If you see my original post you'll see that I edited it from an 8 to 11 when I realised) :rolleyes:

Happy it worked for you and welcome to the board :)
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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