View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Code to replace specific text

Hi Steve,

Am Fri, 17 Nov 2017 08:30:05 -0800 (PST) schrieb
:

Thanks very much for your reply. I have just tried it after making a couple of minor tweaks (we've inserted a couple if new columns and so it's cols I and J now, but obviously I amended the corresponding parts of your code - perhaps incorrectly).

I think I see what it's looking to do, but it's removing the top line and moving everything else up one row...


I think you have headers in your table. Then try:

Sub ReplaceText()
Dim LRow As Long, i As Long
Dim varData As Variant

With ActiveSheet
LRow = .Cells(.Rows.Count, "I").End(xlUp).Row
varData = .Range("I2:J" & LRow)
For i = LBound(varData) To UBound(varData)
If varData(i, 1) = "No Description" Then
varData(i, 1) = varData(i, 2)
End If
Next
.Range("I2").Resize(UBound(varData), 2) = varData
End With
End Sub


Regards
Claus B.
--
Windows10
Office 2016