+ Reply to Thread
Results 1 to 6 of 6

Find first date of the month in range and return column number

  1. #1
    Registered User
    Join Date
    08-23-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    18

    Find first date of the month in range and return column number

    Hey all,

    Having a bit of difficulty getting some code to work here. I have a row of cells R3:BC3 that will contain 38 dates. R3 will be the first of a month, then go out through the month, and the first week-ish of the next month.

    For example, this month is september, so R3 will be 8/1/2013 and BC3 will be 9/7/2013.
    Next month, October, R3 will be 9/1/2013, and BC3 will be 10/8/2013.

    38 days total.

    I need to search my range R3:BC3 to find the first the first day of the month, then return the column number. Here's what I have so far, but I'm getting a "Unable to get the Match property of the WorksheetFunction class" error.

    Please Login or Register  to view this content.
    Thanks in advance for any help!

  2. #2
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Find first date of the month in range and return column number

    use find instead of match...
    http://msdn.microsoft.com/en-us/libr.../ff839746.aspx

    Please Login or Register  to view this content.
    Please click the * below if this helps

  3. #3
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Find first date of the month in range and return column number

    I think there is a data type problem, what is the format in the row 3?

  4. #4
    Registered User
    Join Date
    08-23-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Find first date of the month in range and return column number

    Please Login or Register  to view this content.
    I'm getting a syntax error with seperators with that....
    Edit: Oh duh, missing paren in first range, no idea how i didn't see that.... code works great thanks! I generally avoid .find as I seem to just never be able to get it to work right. Thanks again.


    The format for row 3 is set as a date with 'dd-mmm' format.

    Still curious about what wasn't work as intended in my original code though.
    Last edited by jben86; 09-06-2013 at 07:43 PM.

  5. #5
    Forum Contributor
    Join Date
    03-21-2012
    Location
    Ho Chi Minh city
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: Find first date of the month in range and return column number

    PHP Code: 
    Option Explicit
    Sub gpeFindFDate
    ()
     
    Dim Rng As RangesRng As Range
     Dim Dat 
    As Date:                           Dim Format_ As String
     
     Set Rng 
    Range([R3], [R3].End(xlToRight))
     
    Dat DateSerial(Year(Date), Month(Date), 1)
     
    Format_ Rng.NumberFormat
     Rng
    .NumberFormat "MM/DD/yyyy"
     
    Set sRng Rng.Find(Format(Dat"mm/dd/yyyy"), , xlValuesxlWhole)
     If 
    Not sRng Is Nothing Then MsgBox sRng.Column
     Rng
    .NumberFormat Format_
    End Sub 

  6. #6
    Registered User
    Join Date
    08-23-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Find first date of the month in range and return column number

    Please Login or Register  to view this content.
    Bah! Ok, just figured it out. You were right rcm, data type problem. I fixed it with Clng.

    Please Login or Register  to view this content.

+ 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] Vlookup date range to return month
    By AW76 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-06-2013, 06:21 AM
  2. [SOLVED] Find specific cell and return column number from a dynamic range
    By nivoe in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-18-2012, 12:39 PM
  3. [SOLVED] lookup date within date range grid to return fiscal month value
    By tigerseye001 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-10-2012, 02:27 PM
  4. Replies: 4
    Last Post: 03-01-2012, 04:27 PM
  5. Replies: 3
    Last Post: 09-25-2007, 10:26 AM

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