Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 4 of 4

Thread: VBA: FIND FIRST ROW

  1. #1
    Join Date
    1st August 2003
    Posts
    62

    VBA: FIND FIRST ROW

    Hi,

    FINDING THE FIRST ROW FOR "KVV"

    When I do a filter to the Segment Code for "KVV" , the first row for "KVV" is Row 4.

    I have done a Marco to help me find the FIRST ROW of "KVV" but the marco will not go and find the FIRST ROW of "KVV" it will just find the Second Row.

    I want the marco help me find the first row of "KVV", that is Row 4.

    How am I going to do that??
    see attract file to have a clearer view.

    THANK YOU…

    Code:

    Sub Macro1()
    '

    '
    column1 = Range("A1").End(xlToRight).Column


    Range(Cells(1, 1), Cells(1, column1)).Select

    Selection.AutoFilter
    Selection.AutoFilter Field:=5, Criteria1:="KVV"


    'it will not offset to the fourth row of "KVV"
    'it will select two row, WHY?

    Cells(1, 5).Offset(1, 0).Select

    firstrow = ActiveCell.Row
    firstcolumn = ActiveCell.Column

    End Sub

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    24th January 2003
    Location
    Perth, Australia
    Posts
    650
    Hi LTT

    Have a look at the attached file. It uses the Find method to get what you want.

    See if does what you want.

    A few tips for your variable names. Always Dim all your variables. Instead of firstrow use FirstRow this then allows you ensure that Excel has recognised the variable if you type it in lower case Excel wil change it to uppercase.

    HTH

    Sub FindKVV()
    '
    ' FindKVV Macro
    ' Macro recorded 01-10-2003 by Neale Blackwood
    '

    Dim FirstRow
    Dim FirstColumn

    Columns("E:E").Select
    Selection.Find(What:="KVV", After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False).Activate

    FirstRow = ActiveCell.Row
    FirstColumn = ActiveCell.Column
    MsgBox "The Row is " & FirstRow & " the column number is " & FirstColumn

    End Sub

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    24th September 2003
    Location
    Warrandyte - Aussieland
    Posts
    212
    Hi LTT, Neale,

    I am not sure this will help but the 'Match' function will identify the row number of an array when seeking a particular string.

    Does this help?

    GrahamB

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    1st August 2003
    Posts
    62
    hi Neale, GrahamB

    Thank you Neale and thanks for your advice about Dim all the variables.

    thank You GrahamB... your method can help me identify the row number... thanks

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Find In VBA Code: Find Exact Match
    By jamesparker_1 in forum EXCEL HELP
    Replies: 4
    Last Post: October 10th, 2006, 16:17
  2. Replies: 3
    Last Post: October 9th, 2006, 00:04
  3. Macro - VBA Script - Find and then Find/Copy/Paste
    By JayMoore in forum EXCEL HELP
    Replies: 1
    Last Post: June 13th, 2006, 06:13
  4. Find Feature to Find 3, or more, Matching Criteria
    By Dave Hawley in forum Excel FAQ
    Replies: 0
    Last Post: August 16th, 2005, 11:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
porno