Thread: [Solved] Paste value of formula
View Single Post
 
Old 09-03-2021, 08:12 PM
Purfleet Purfleet is offline Windows 10 Office 2019
Expert
 
Join Date: Jun 2020
Location: Essex
Posts: 345
Purfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to behold
Default

Okay, if i understand correctly i think you were trying to do too much - the Macro should be able to do it all

Attached are 2 macros

Join Active

will join the active cell to the cell to the right with a ": " in between and then delete the cell to the right

Code:
Sub JoinActive()

    ActiveCell = ActiveCell & ": " & ActiveCell.Offset(0, 1)

    ActiveCell.Offset(0, 1).Cells.ClearContents

End Sub
JoinAll

Will look at every cell in column b and join it to the cell to the right with a ": " in between - this one takes a few seconds as it is looking at 1million rows.

Code:
Sub JoinAll()

    Dim Col1 As Range 'left column to join
    Dim Col2 As Range 'right column to join
    Dim r1 As Range ' for looping
    
    Set Col1 = ActiveSheet.Range("B:B")
    Set Col2 = ActiveSheet.Range("c:c")
    
    For Each r1 In Col1
        If r1.Value <> "" Then
            r1 = r1 & ": " & r1.Offset(0, 1)
        End If
        
    Next r1

    Col2.Cells.ClearContents

End Sub
Both of these could easily be made more efficent and flexible but hopefully its a start
Attached Files
File Type: xlsm Copy of Copy value of formula-1.xlsm (20.9 KB, 8 views)
Reply With Quote