Results 1 to 7 of 7

VBA Code (date format) should correspond with custom dateformat

Threaded View

  1. #1
    Forum Contributor
    Join Date
    01-23-2020
    Location
    Namibia
    MS-Off Ver
    2016
    Posts
    117

    VBA Code (date format) should correspond with custom dateformat

    Good morning

    I have been trying for three weeks now to get this right but after watching videos and trying everything cant seem to get it to work.

    I have a file that when you type things in certain cells, it automatically creates a date stamp in cell "I"

    I then have a macro to copy the fields to another file that must be opened (I use a macro for that)

    then the file where everything copied must be saved with the new information and then uploaded to a website.

    the problem is that when it copies, the date changes to a number. I did watch various videos to make it correct but does not seem to work.

    So I am uploading three small excel files.

    Book2.xlsm is the file where you type in anything then it will generate a date stamp in cell "I"
    Results.xls (and it must not be a macro enabled file) is the one that must be uploaded. there is a macro on the sheet when u click it will copy the info over.

    make sure Results.xls is open before running the macro.

    When you copy the results over, it overrides the values and format in cell "I' and then the date shows as a number which gives an sql error when I upload it to a specific website.

    I am therefore also copying the file called "date file" so you can see what the correct format should be.


    What I am asking is can you not adjust the vba code is Book2 so that it can correspond with the format and value in date file?


    I removed sensitive information.


    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim i As Integer
    For i = 6 To 24
    If Cells(i, "B").Value <> "" And Cells(i, "H") <> "" And Cells(i, "J") = "" Then
    
    Cells(i, "J").Value = Date & " " & time
    Cells(i, "J").NumberFormat = "m/d/yyyy h:mm"
    
    
    End If
    Next
    Attached Files Attached Files
    Last edited by Stona; 03-02-2020 at 05:40 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Adjust code to fit a Mac computer
    By ammartino44 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-11-2018, 11:54 PM
  2. [SOLVED] vba code to adjust round value at random
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-16-2017, 07:52 AM
  3. help to adjust my macro code
    By Muhammad Waheed in forum Word Programming / VBA / Macros
    Replies: 4
    Last Post: 04-13-2016, 09:13 PM
  4. Can Someone Please Adjust This Code to Increase Speed?
    By smcmahon83 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-14-2015, 03:09 PM
  5. [SOLVED] Adjust code to run OnClick only
    By clarkyblade in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-22-2015, 04:12 AM
  6. Adjust the code in the Web Query
    By win1980 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-30-2013, 11:21 PM
  7. Auto Adjust VBA Code
    By skankingpigeon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-17-2012, 04:31 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