+ Reply to Thread
Results 1 to 6 of 6

Combining 2 columns into one without losing its format

  1. #1
    Registered User
    Join Date
    10-24-2022
    Location
    Tokyo
    MS-Off Ver
    MS Office 2021
    Posts
    3

    Combining 2 columns into one without losing its format

    Dear All,

    I need help combining 2 columns into one without losing its formatting.
    One column has date format and the other one is number format.
    I attached the sample date. In column D, I need to show it the same format as the column from which I pulled.
    Can anyone help me?

    Thank you.
    Attached Files Attached Files

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,641

    Re: Combining 2 columns into one without losing its format

    Try with VBA code. Click the button "COMBINE" to run

    PHP Code: 
    Option Explicit
    Sub test
    ()
    Dim cell As Range
    Range
    ("D2:D100000").ClearContents
    For Each cell In Range("B2:B" Cells(Rows.Count"A").End(xlUp).Row)
        
    With cell.Offset(, 2)
            If 
    Len(cell) = 0 Then
                
    .Value cell.Offset(, 1).Value
                
    .NumberFormat "0"
            
    Else
                .
    Value cell.Value
                
    .NumberFormat "dd/mm/yyyy"
            
    End If
        
    End With
    Next
    End Sub 
    Attached Files Attached Files
    Quang PT

  3. #3
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Combining 2 columns into one without losing its format

    If you don't mind the result become text.
    Please try

    =IF(B2="",TEXT(C2,"0"),TEXT(B2,"dd/mm/yyyy"))

    Note: Original data (B and C) needed.

    Regards.

  4. #4
    Registered User
    Join Date
    10-24-2022
    Location
    Tokyo
    MS-Off Ver
    MS Office 2021
    Posts
    3

    Re: Combining 2 columns into one without losing its format

    Thank you for your suggestion. Let me try it first

  5. #5
    Registered User
    Join Date
    10-24-2022
    Location
    Tokyo
    MS-Off Ver
    MS Office 2021
    Posts
    3

    Re: Combining 2 columns into one without losing its format

    Thank you. I tried it already and it worked.

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,686

    Re: Combining 2 columns into one without losing its format

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ 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. Combine 3 Columns into 1 Cell - Without Losing Format
    By watson150 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-08-2020, 08:53 PM
  2. Combining multiple rows into one column without losing data
    By ChristSeeker72986 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 10-25-2016, 11:19 AM
  3. Text to Columns losing date format
    By PaulG2015 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2016, 10:48 AM
  4. Replies: 7
    Last Post: 07-23-2013, 02:57 AM
  5. Replies: 1
    Last Post: 06-05-2013, 08:06 AM
  6. Replies: 1
    Last Post: 11-05-2012, 12:52 AM
  7. [SOLVED] Combining two cells, losing formats
    By johnlynches in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-04-2012, 12:15 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