+ Reply to Thread
Results 1 to 5 of 5

The data in the remarks column is exchanged with the data in a certain area

Hybrid View

  1. #1
    Registered User
    Join Date
    08-31-2020
    Location
    Japan
    MS-Off Ver
    2016
    Posts
    94

    The data in the remarks column is exchanged with the data in a certain area

    Can the data in the remarks column be exchanged with the data in a certain area and keep the original format unchanged?

    Cell M1 is a switch between NEW and OLD, if it is NEW, the I6:I36 data will not change from the original format

    If cell M1 is OLD, the data in the remark column of I6:I36 will be switched to I6:I36, and the original data of I6:I36 will be switched to the remark column, exchanged with each other and keep the original format unchanged

    When CELL M1 selecting NEW to change to the original appearance

    Any help is greatly appreciated
    Attached Files Attached Files
    Last edited by Sakurayuki; 03-08-2023 at 10:33 AM.

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,046

    Re: The data in the remarks column is exchanged with the data in a certain area

    Maybe something like this in the worksheet code.

    Dim PrevValue
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rng As Range, cell As Range
    Dim cmt As Comment
    Dim o As String, n As String
    
    On Error GoTo errHandler
    Set rng = Range("I16:I36")
    If Target.Count = 1 And Target.Address = "$M$1" Then
        If IsEmpty(PrevValue) Then
            Application.EnableEvents = False
            Application.Undo
        Else
            If Target.Value <> PrevValue And (UCase(Target.Value) = "NEW" Or UCase(Target.Value) = "OLD") Then
                Application.EnableEvents = False
                For Each cell In rng.Cells
                    With cell
                        o = .Value
                        Set cmt = .Comment
                        If Not cmt Is Nothing Then
                            n = cmt.Text
                            .Comment.Delete
                            If Len(n) Then
                                .Value = n                            
                               If Len(o) Then .AddComment o
                            End If
                         End If
                    End With
                Next
            End If
        End If
    End If
    
    Application.EnableEvents = True
    PrevValue = [M1].Value
    Exit Sub
    
    errHandler:
    MsgBox Err.Description, vbCritical
    Application.EnableEvents = True
    End Sub
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    PrevValue = [M1].Value
    End Sub

  3. #3
    Registered User
    Join Date
    08-31-2020
    Location
    Japan
    MS-Off Ver
    2016
    Posts
    94

    Re: The data in the remarks column is exchanged with the data in a certain area

    Hi ByteMarks Thank you very much, that’s what it means. When Cell M1 selects OLD, keep the ROW HEIGHT without increasing the height. It is the same as the attachment format. Where should the code be changed?

  4. #4
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,046

    Re: The data in the remarks column is exchanged with the data in a certain area

    I think the row height changes because the comments contain a carriage return.

  5. #5
    Registered User
    Join Date
    08-31-2020
    Location
    Japan
    MS-Off Ver
    2016
    Posts
    94

    Re: The data in the remarks column is exchanged with the data in a certain area

    The meaning is completely to the taste, only this step is left, it is perfect, thank you again

+ 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] The input data in the area is automatically sorted, plus the serial number and remarks
    By Sakurayuki in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-29-2022, 12:55 AM
  2. Remove duplicates which is exchanged in 2 column cells
    By Sekars in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-01-2018, 04:32 AM
  3. VBA Print area Last Row and Last Column - With Blanks in Data
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-02-2016, 01:02 PM
  4. Save remarks/comments to Pivot table and chart data
    By Popopinsel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-23-2013, 05:25 AM
  5. Sorting data from a column to corresponding area
    By alex.ransome in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2013, 06:59 AM
  6. [SOLVED] In Remarks Column the Remarks should be as described as the attached excel file
    By robin.das077 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-30-2013, 03:38 AM
  7. Replies: 4
    Last Post: 06-11-2012, 01:22 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