+ Reply to Thread
Results 1 to 6 of 6

Issue when copying cells (defaults to mm/dd/yyyy when im wanting dd/mm/yyyy)

Hybrid View

markpem Issue when copying cells... 12-19-2014, 11:04 AM
xladept Re: Issue when copying cells... 12-19-2014, 04:42 PM
markpem Re: Issue when copying cells... 12-22-2014, 07:59 AM
cytop Re: Issue when copying cells... 12-22-2014, 08:22 AM
markpem Re: Issue when copying cells... 12-22-2014, 08:31 AM
xladept Re: Issue when copying cells... 12-22-2014, 06:04 PM
  1. #1
    Registered User
    Join Date
    12-15-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    18

    Issue when copying cells (defaults to mm/dd/yyyy when im wanting dd/mm/yyyy)

    Hello All,

    I have some code below that looks for any changes and finds the match on the other sheet and updates any changes, however the dates when transferred over go from the UK formatiing of dd/mm/yyyy to the US style date of mm/dd/yyyy making all the dates in the sheet incorrect.

    Could someone help and advise how I make it stay the same way? Thanks!"


    Dim s1rw As Long, s2rw As Long, col As Long, endcol As Long
    
        Sheets("Sheet1").Select
        With Sheets("Sheet2")
            s2rw = 2 ' Adjust to first data row #
            endcol = .Cells(s2rw - 1, 1).End(xlToRight).Column
            Do Until .Cells(s2rw, 1).Value = "" ' Loop through case #s
                s1rw = 0
                On Error Resume Next
                s1rw = Cells.Find(What:=.Cells(s2rw, 1).Value, LookIn:=xlFormulas, LookAt:=xlWhole).Row
                On Error GoTo 0
                If s1rw > 0 Then ' Found case #
                    For col = 1 To endcol ' Loop through columns
                        If Cells(s1rw, col).Value <> "" Then
                            .Cells(s2rw, col).Value = Cells(s1rw, col).Value
                        End If
                      Next
                End If
              Rows(s2rw).Delete
                s2rw = s2rw + 1
            Loop
            .Select
        End With
    Last edited by markpem; 12-22-2014 at 07:35 AM.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Issue when copying cells (defaults to mm/dd/yyyy when im wanting dd/mm/yyyy)

    Maybe:

    If Cells(s1rw, Col).Value <> "" Then
        If IsDate(Cells(s1rw, Col).Value) Then
    .Cells(s2rw, Col).Value = Format(Cells(s1rw, Col).Value, "dd/mm/yyyy")
    Else
    .Cells(s2rw, Col).Value = Cells(s1rw, Col).Value
    End If: End If
    **Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    12-15-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    18

    Re: Issue when copying cells (defaults to mm/dd/yyyy when im wanting dd/mm/yyyy)

    Hello

    First of all XLadept I want to thank you for spending the time regading my issue but it doesnt look like it's worked.

    I did a search and came up with: - http://stackoverflow.com/questions/9...-automatically

    There is some info on there that might help on my code, would you be able to look?

    Thanks

    MarkPem
    Last edited by markpem; 12-22-2014 at 08:10 AM.

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Issue when copying cells (defaults to mm/dd/yyyy when im wanting dd/mm/yyyy)


  5. #5
    Registered User
    Join Date
    12-15-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    18

    Re: Issue when copying cells (defaults to mm/dd/yyyy when im wanting dd/mm/yyyy)

    Quote Originally Posted by cytop View Post
    Hello, Yes your right. I did crosspost. I was blissfully unware that it was against forum rules and I have been shown the error of my ways.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Issue when copying cells (defaults to mm/dd/yyyy when im wanting dd/mm/yyyy)

    Maybe if you format the post:

    Format(.Cells(s2rw, Col), "dd/mm/yyyy") = Cells(s1rw, Col)

+ 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] Issue in macro to convert date from DD-MON-YYYY into YYYY-MON-DD
    By abraham30 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-20-2014, 09:17 AM
  2. Replies: 7
    Last Post: 11-18-2012, 02:28 PM
  3. [SOLVED] Imported data contains strings dd.mm.yyyy how can I convert to date format dd/mm/yyyy inVB
    By Boormo in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-05-2012, 05:48 PM
  4. Copy+Paste macro dd/mm/yyyy to dd/mm/yyyy and NOT dd/mm/yyyy to mm/dd/yyyy
    By uimhirADo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2012, 03:45 AM
  5. [SOLVED] opening excel file -> date format problem: DD/MM/YYYY vs MM/DD/YYYY
    By yung in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-18-2005, 09:06 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