+ Reply to Thread
Results 1 to 2 of 2

syntax code for date

Hybrid View

  1. #1
    Registered User
    Join Date
    10-10-2014
    Location
    seattle wa
    MS-Off Ver
    2007
    Posts
    63

    syntax code for date

    Hi All,

    I am recording a macro and it will run 1st day of the month. For example it's pulling PI data on 6/1/2016 and in column A3, i would like to populate "7/1/2016" when I run it on July 1st. What code do i need, in order for macro to do that.

    Current Macro example:

    Sub Macro1()
    '
    ' Macro1 Macro
    '

    '
    Range("A2").Select
    ActiveCell.FormulaR1C1 = "7/1/2016"
    Range("A3").Select
    End Sub

    Thank you

  2. #2
    Registered User
    Join Date
    05-12-2016
    Location
    NZ
    MS-Off Ver
    Office 14
    Posts
    41

    Re: syntax code for date

    Try:

    With Range("A2") 'This could be a multiple cells if you needed - "A2:A3", etc.
            .Value = Date
            .NumberFormat = "mm/dd/yyyy"
    End With

+ 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. SQL code in VBA - incorrect syntax near
    By michiel soede in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-02-2015, 10:00 AM
  2. Need help to fix the syntax of my code
    By JayeshG in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-05-2015, 06:53 PM
  3. [SOLVED] code syntax
    By lundy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-14-2014, 01:33 PM
  4. code syntax
    By cmccabe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-10-2013, 01:16 AM
  5. [SOLVED] Syntax error in code
    By JOUIOUI in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-10-2006, 11:10 AM
  6. [SOLVED] Syntax of VBA Code
    By Ken Hudson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-14-2005, 06:05 PM
  7. [SOLVED] Syntax of this code
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2005, 07:06 AM

Tags for this Thread

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