Consulting

Results 1 to 3 of 3

Thread: Solved: Excel 2000 to 2003 compatibility issue with .Find

  1. #1
    VBAX Regular
    Joined
    Jun 2004
    Posts
    36
    Location

    Solved: Excel 2000 to 2003 compatibility issue with .Find

    I have a spreadsheet with data for multiple company branches. We are splitting the data into separate reports for each branch.

    When creating a branch report, we first copy the worksheet to a new workbook, find the last entry for that branch, then delete any rows below that.

    To find the last row of data for any given branch, we have always used this
    (DestCol is the column number, Destination is the branch name):
    [VBA]Columns(DestCol).Find(What:=Destination, After:=Cells(65536, DestCol), _
    LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
    SearchDirection:=xlUp, MatchCase:=False).Select
    [/VBA]
    and it has always worked fine under Excel 2000.

    One member of our group just got a new laptop that has Excel 2003... and now that same line of code (which still works fine under 2000) doesn't find the last row of data for that branch, it finds the first!

    Can anyone offer any insight to why this may be happening?

    Thx
    Wizard

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Greetings,

    Try changing the xlSearchDirection.

    [vba]Dim DestCol As Long
    Dim Destination As String
    Destination = "Example Branch"
    DestCol = 2

    Columns(DestCol).Find(What:=Destination, After:=Cells(65536, DestCol), _
    LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
    SearchDirection:=xlPrevious, MatchCase:=False).Select[/vba]

    I'm not where I can get to 2000, but seems I recall (seems as in I may well be wrong) that xlPrevious works in 2000 as well... maybe?

    Mark

  3. #3
    VBAX Regular
    Joined
    Jun 2004
    Posts
    36
    Location
    Well we're not going to find out if that works or not... they downgraded her Office version back to 2000, so the question is now moot.

    I'll mark it solved just the same... after all, it is solved, just not via VBA code.

    Thanks just the same!

Posting Permissions

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