Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Firstrow

Status
Not open for further replies.

Mattprd

IS-IT--Management
Mar 12, 2002
11
GB
The following code locates a cell that I would like to select as my firstrow, Can someone explain, how I can set the firstrow from this code.

Cells.Find(What:="Press", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=True)

thanks

Matt
 
Hi,
you are close. You have defines a range object. By adding a .Row property, you can get the row...
Code:
    Dim lRow As Long
    lRow = Cells.Find(What:="Press", After:=ActiveCell, LookIn:=xlFormulas, _
                         LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                         MatchCase:=True).Row
BUT...
if you assign that range object to a defined range object, there is alot of stuff that you might want to do with that range, like this...
Code:
    Dim lRow As Long, rng As Range, iCol As Integer
    Set rng = Cells.Find(What:="Press", After:=ActiveCell, LookIn:=xlFormulas, _
                         LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                         MatchCase:=True)
    With rng
        lRow = .Row
        iCol = .Column
        .Font.ColorIndex = 3
    End With
   MsgBox "Row is " & lRow & ", Column is " & iCol
Hope this helps :) Skip,
metzgsk@voughtaircraft.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top