Find a date in Excel of a specifed range RRS feed

  • Question

  • Plz give me a solution for finding a date in Excel of Specified range

    Here in my case I just want to find "1/3/2011 "  between the range G7 to AJ   using vb.net

    Right now i am using the code to find it


    Dim proc As System.Diagnostics.Process


    Dim intPID As Integer


    Dim iHandle As IntPtr


    Dim xlApp As Excel.Application


    Dim xlWorkBook As Excel.Workbook


    Dim xlWorkSheet As Excel.Worksheet

    xlApp =

    New Excel.ApplicationClass

    xlWorkBook = xlApp.Workbooks.Open(OpenBookingDlg.FileName)

    xlWorkSheet = xlWorkBook.Worksheets(2)


    Dim rngFound As Excel.Range = Nothing


    Dim rngLookIn As Excel.Range = Nothing


    Dim rngData As Excel.Range = Nothing


    Dim iLastRow As Long


    Dim iLastColumn As Long


    Dim EndColumn As Long


    ' Dim i As Integer

    iLastRow = xlApp.ActiveSheet.Cells(xlApp.Rows.Count, 2).End(xlUp).Row

    iLastColumn = xlApp.ActiveSheet.Cells(7, xlApp.Columns.Count).End(xlToLeft).Column()

    EndColumn = xlApp.ActiveSheet.Cells(iLastRow, xlApp.Columns.Count).End(xlToLeft).Column()

    EndPosition = xlApp.Cells(iLastRow, EndColumn - 1).Address

    EndPosition = EndPosition.Replace("$",



    Dim strCol As String = xlApp.Cells(7, iLastColumn - 1).Address

    strCol = strCol.Replace("$",


    rngLookIn = xlApp.Range("G7:" & strCol)


    'With rngLookIn


    'rngFound = .Find(dtlDate.Value, After:=.Cells(.Count))

    rngFound = rngLookIn.Find(What:=dtlDate.Value)

    here i am always getting nothing. Actualy value is there but it return nothing. i am worried abt  Plz help as soon as possible early. I try it with one week


    Thursday, May 19, 2011 12:16 PM


  • Hi,


    Since this is Windows SteadyState Forum, please contact Windows Office Forum for further help:




    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.  Thank you for your understanding.





    Leo   Huang



    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Leo Huang Monday, May 23, 2011 8:13 AM
    Friday, May 20, 2011 7:31 AM