Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2008

Tip: Looking for answers? Try searching our database.

Macro / vb query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dan Thompson - 16 Jan 2008 09:26 GMT
I am trying to set up a macro that will find a row based on a specific word,
then underline that row in the table.

I've tried recording it, and the find bit is fine, but I don't know how to
change the vb code to allow it to highlight columns 1 through 7 on the row
that has been found.  At the moment, the code points to specific cells:

Range("A7:E7").Select

Any ideas please?

Thanks, Dan.
filo666 - 16 Jan 2008 10:00 GMT
This sshould work.
notes:
you must select the table first
change df for what you are looking for.

Sub lookfor()
Dim Var1 As Integer
On Error GoTo HE
Selection.Find(What:="df", After:=ActiveCell, LookIn:=xlFormulas, _
       LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
       MatchCase:=False, SearchFormat:=False).Activate
Var1 = ActiveCell.Column
Columns(Var1).Font.Underline = xlUnderlineStyleSingle
End
HE:
MsgBox "not found", vbCritical, "Not found"
End Sub

HTH

> I am trying to set up a macro that will find a row based on a specific word,
> then underline that row in the table.
[quoted text clipped - 8 lines]
>
> Thanks, Dan.
Lazzzx - 16 Jan 2008 13:54 GMT
Hi,

This code will highlight (yellow background) columns 1 to 7 (A:G) in the row
where activecell is.

With ActiveCell.End(xlToLeft).Resize(1, 7)
       .Interior.ColorIndex = 6
       .Interior.Pattern = xlSolid
End With

if the left column of your table is not column A, you can add an offset. Eg,
this will highlight columns C:I

With ActiveCell.End(xlToLeft).Resize(1, 7).Offset(0, 2)
       .Interior.ColorIndex = 6
       .Interior.Pattern = xlSolid
End With

With this code it does not matter in which column you find the word you are
searching for.

regards
Lazzzx

>I am trying to set up a macro that will find a row based on a specific
>word,
[quoted text clipped - 9 lines]
>
> Thanks, Dan.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.