• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Add a string to a range columns

Vijayarc

Member
Hi Ninjas

Below and attached sheet is my sample database, where i need to add "Days" at end of numbers in each cell in all columns.
i have code that works for A columns , i want the code that work at all column range .. i tried range of ("A:H") But it not woking
please help and Thanks in advance !!!

Code:
Sub AppendToExistingOnRight()
Dim LastRow As Long, i As Long
LastRow = Range("A" & Rows.Count).End(xlUp).Row
 For i = 2 To LastRow
If Range("A" & i).Value <> " - " Then
Range("A" & i).Value = Range("A" & i).Value & " Days"
 End If
Next i
End Sub

Global TradeIS-ACCEIS-BDSIS Prime BrokerageIS-Depository ReceiptsKYCLATAM ChileLATAM-Argentina
No Relationship - 7 DaysNo Relationship - 3Rejected - 160 - No Relationship - 1Not Started - - -
No Relationship - 3 DaysCompleted - 8Rejected - 119 - No Relationship - 9Not Started - - -
No Relationship - 2 DaysNo Relationship - 7Rejected - 224 - No Relationship - 2Not Started - - -
No Relationship - 2 DaysNo Relationship - 7Rejected - 224 - No Relationship - 2Not Started - - -
No Relationship - 6 DaysNo Relationship - 8No Relationship - 8 - No Relationship - 1Not Started - - -
No Relationship - 8 DaysNo Relationship - 6Rejected - 124 - No Relationship - 5No Relationship - 3 - -
 

Attachments

  • test..xlsm
    9.6 KB · Views: 4
Code:
Sub AppendToExistingOnRight()

Dim LastRow As Long
Dim Rng As Range
Dim SubRng As Range

LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set Rng = Range("A2:D" & LastRow)


For Each SubRng In Rng
    If SubRng.Value <> " - " Then
        SubRng.Value = SubRng.Value & " Days"
    End If
Next SubRng

End Sub
 
Back
Top