Use VB to move to adjacent cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I know that this is a simple question, but I can't find the answer. I have
the VB code to find a cell in a worksheet. I would then like to have the
adjacent cell to the right highlighted. What is the code for that?

Thanks
B
 
Dim Foundcell as range

set foundcell = yourfindgoeshere

if foundcell is nothing then
beep
else
foundcell.offset(0,1).select
end with

(assuming you're finding on the activesheet.)
 
Try something like

Dim FoundCell As Range
Set FoundCell Cells.Find(....)
If Not FoundCell Is Nothing Then
FoundCell(1,2).Select
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting LLC
www.cpearson.com
(email on the web site)
 
If your VB code identifies a cell:

rngFoundCell.Offset(, 1).Select

If it just selects a cell:

ActiveCell.Offset(, 1).Select

________________________________________________________________________
 
I need to become a lot faster to beat Dave and Chip!
________________________________________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top