+ Reply to Thread
Results 1 to 3 of 3

Formatting a date from userform, then filtering.

Hybrid View

Ash_ Formatting a date from... 07-21-2014, 01:06 PM
Norie Re: Formatting a date from... 07-21-2014, 01:11 PM
Ash_ Re: Formatting a date from... 07-21-2014, 01:15 PM
  1. #1
    Registered User
    Join Date
    05-24-2013
    Location
    Hampshire
    MS-Off Ver
    Office 2013
    Posts
    49

    Formatting a date from userform, then filtering.

    Hello Guys!

    Got a slight problem which I cannot seem to get my head around. I have a userform which writes a date into a cell within a row within a table. The code is

     .Offset(0, 8) = Format(Reg9.Value, "dd/mm/yy")
    Everything works fine, the date gets sent to the cell as stated and is all correct. However, I also have vba which runs an advanced filter, which the following code is included in.

                .Range("P7").Value = "=""<""&TODAY()" & "+7"
                .Range("O7").Value = "="">""&TODAY()"
    P7 and O7 are the advanced filter criteria. Basically in the form I have a "completion date" which is posted with the first code I posted. So lets say that the date posted is 25/07/14, and I want to have a filter of all the dates which are coming up in the next 7 days to be shown in the Advanced Filter results area of my spreadsheet.

    With the second part of code I posted, this results in nothing when using the advance filter. The original posted date in the cell (from the first code) is shown as "25/07/14". So when I run the advanced filter, nothing happens. HOWEVER, if I go to the cell containing "25/07/14", delete the contents and write "25/07/14" manually and then run the advanced filter (second code posted), the date shows up in the results working fine. But I dont understand how me typing it out again makes it work?

    Hope I am making myself clear?

    Many thanks in advance!

    Ash

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Formatting a date from userform, then filtering.

    Does the filter work if you use this to put the date in the cell?
     .Offset(0, 8) = DateValue(Reg9.Value)
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    05-24-2013
    Location
    Hampshire
    MS-Off Ver
    Office 2013
    Posts
    49

    Re: Formatting a date from userform, then filtering.

    Quote Originally Posted by Norie View Post
    Does the filter work if you use this to put the date in the cell?
     .Offset(0, 8) = DateValue(Reg9.Value)
    Yes, yes it does! Awesome.

    Thanks very much, do appriciate that!

+ 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. How to filtering in a userform
    By fraz627 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-07-2013, 05:45 PM
  2. Linking a Userform to a Table and filtering it.
    By BigJohnW in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-03-2012, 04:03 PM
  3. Excel 2007 : Filtering Data from excelsheet on the Userform
    By qiqinuinaifen128 in forum Excel General
    Replies: 1
    Last Post: 01-11-2012, 09:17 AM
  4. [SOLVED] Userform Date Formatting MM/DD/YYYY
    By Mike in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-09-2010, 12:51 AM
  5. Trouble with filtering in userform
    By bernie1961 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-22-2008, 09:34 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