+ Reply to Thread
Results 1 to 3 of 3

Find Date and Capture Row Number of That Cell

  1. #1
    Registered User
    Join Date
    07-18-2011
    Location
    Ruidoso NM
    MS-Off Ver
    Excel 2010
    Posts
    62

    Find Date and Capture Row Number of That Cell

    Working something in Access VBA that, at one point, needs to find a particular date in an Excel spreadsheet and capture its row, so that and all subsequent data rows can be deleted. (Dates are all in Column A, and go all the way back to the 1980's.) Trying to do this from Access VBA, I keep getting errors about object(s) not being declared or something like that. An object identifying the Excel worksheet is being passed to the procedure, and my "find" code starts with ExcelWorksheet.Cells.Find (followed by all the usual arguments), which is what I get if I attempt to do the same thing directly in Excel, so not sure what the problem is. Any tips? This has me scratching my head.

    PS, the procedure is manipulating the Excel spreadsheet in a number of other ways without problem, it's just this "find" bit that isn't working.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Find Date and Capture Row Number of That Cell

    Hi ikslohap,

    Dates can be tricky to work with. Please upload a sample Excel File that contains a few typical dates that you want to find. The dates MUST be in exactly the same format as the dates in your actual file.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

    Lewis

  3. #3
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Find Date and Capture Row Number of That Cell

    I don't use Access, so this has not been tested in Access. It has been tested in Excel and PowerPoint. See the attached zip file which contains the following files:
    a. ExcelForumFindDateInNewExcelInstance.xls - File that contains a Macro to find a Date in the Excel Data File (in another instance of Excel) and Delete all rows in the Excel Data File after the 'Date'.
    b. ExcelForumFindDateInNewExcelInstance.ppt - Same as the previous file, but runs from PowerPoint. Code is identical except for the items in red below.
    c. ExcelForumFindDateInColumnADataFile.xls - The Data File.
    d. ExcelForumFindDateInColumnADataFileMaster.xls - Master Copy of the 'Data File' which can be used to make a fresh 'Original Copy' of the 'Data File', if the 'Data File' gets modified.

    Code follows:
    Please Login or Register  to view this content.

    It is a best practice to declare all variables. If you misspell a variable in your code, VBA will silently assume it is a Variant variable and go on executing with no clue to you that you have a bug. Go to the VBA development window, click Tools, Options, and check "Require Variable Declaration." This will insert the following line at the top of all new modules:
    Please Login or Register  to view this content.
    This option requires all variables to be declared and will give a compiler error for undeclared variables.

    Lewis
    Last edited by LJMetzger; 01-05-2016 at 05:29 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Find RMA Number and paste the order number and date multiple times
    By intex in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-11-2015, 05:31 PM
  2. Formula to Capture Adjacent Cell Date when Seeking Minimum Value
    By fearonc in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-10-2013, 12:16 AM
  3. Replies: 2
    Last Post: 04-09-2012, 08:21 AM
  4. Replies: 2
    Last Post: 02-27-2012, 09:20 AM
  5. Capture the date and time any cell in the workbook has been updated
    By bigbavarian in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-09-2009, 01:04 PM
  6. How do I capture the Modified date in a cell?
    By rcg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-09-2005, 02:06 PM
  7. Capture cell input date/time
    By Fraggs in forum Excel General
    Replies: 0
    Last Post: 02-03-2005, 12:19 PM

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1