Macro needed to append data to cell in selected column with input string if found
Budget: $2 – $3 USD
I can pay $2 for the first working solution that I test.
I would like to be able to simply select the column that contains cells where I might want data to be appended and run the macro. The macro should then ask for an input string that is not case-sensitive. In this example case, upon entering the word "craigslist", it should look for any occurrence of that string of characters on each row and append it to the end of the cell for that row in the selected column.
Rburke responded with this solution here https://www.experts-exchange.com/questions/29219163/Macro-needed-to-append-column-A-with-input-string-if-found.html#a43307721 and his code is also pasted below.
I have also included the sample sheet with the macro included.
[code]Option Explicit
Sub findAndAppend()
Dim tcell As Range
Dim lookFor As String, firstaddress
Dim fnd As Range ' union of all found cells
lookFor = "craig" ' InputBox("What to find")
If lookFor = "" Then Exit Sub
' \\\\\\\\\\\\\\\ BEGIN "Standard Find All" code finds ALMOST ALL occurances \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
With ActiveSheet.Cells
Set tcell = .Find(What:=lookFor, LookIn:=xlValues, LookAt:=xlPart, _
MatchCase:=False, searchOrder:=xlByRows)
If tcell Is Nothing Then
MsgBox "not found"
Exit Sub
End If
If Not tcell Is Nothing Then
firstaddress = tcell.Address
Do
Dim addit As Boolean ' under some weird circumstances the loop can hit the same cell more than once.
If fnd Is Nothing Then
Set fnd = tcell
addit = True
ElseIf Intersect(fnd, tcell) Is Nothing Then
Set fnd = Union(fnd, tcell)
addit = True
Else
addit = False
End If
If tcell.Row = 13 Then Stop
If addit Then
If tcell.Column > 1 Then
With tcell.EntireRow.Cells(1)
If InStr(1, .Value, tcell, 1) = 0 Then
.Value = .Value & " " & tcell
End If
End With
End If
End If
Set tcell = .FindNext(tcell)
Loop While tcell.Address <> firstaddress
End If
End With
' /////////////// END "STANDARD FIND ALL CODE" ///////////////////////////////////////////////////////////
MsgBox "done"
End Sub[/code]
I would like to be able to simply select the column that contains cells where I might want data to be appended and run the macro. The macro should then ask for an input string that is not case-sensitive. In this example case, upon entering the word "craigslist", it should look for any occurrence of that string of characters on each row and append it to the end of the cell for that row in the selected column.
Rburke responded with this solution here https://www.experts-exchange.com/questions/29219163/Macro-needed-to-append-column-A-with-input-string-if-found.html#a43307721 and his code is also pasted below.
I have also included the sample sheet with the macro included.
[code]Option Explicit
Sub findAndAppend()
Dim tcell As Range
Dim lookFor As String, firstaddress
Dim fnd As Range ' union of all found cells
lookFor = "craig" ' InputBox("What to find")
If lookFor = "" Then Exit Sub
' \\\\\\\\\\\\\\\ BEGIN "Standard Find All" code finds ALMOST ALL occurances \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
With ActiveSheet.Cells
Set tcell = .Find(What:=lookFor, LookIn:=xlValues, LookAt:=xlPart, _
MatchCase:=False, searchOrder:=xlByRows)
If tcell Is Nothing Then
MsgBox "not found"
Exit Sub
End If
If Not tcell Is Nothing Then
firstaddress = tcell.Address
Do
Dim addit As Boolean ' under some weird circumstances the loop can hit the same cell more than once.
If fnd Is Nothing Then
Set fnd = tcell
addit = True
ElseIf Intersect(fnd, tcell) Is Nothing Then
Set fnd = Union(fnd, tcell)
addit = True
Else
addit = False
End If
If tcell.Row = 13 Then Stop
If addit Then
If tcell.Column > 1 Then
With tcell.EntireRow.Cells(1)
If InStr(1, .Value, tcell, 1) = 0 Then
.Value = .Value & " " & tcell
End If
End With
End If
End If
Set tcell = .FindNext(tcell)
Loop While tcell.Address <> firstaddress
End If
End With
' /////////////// END "STANDARD FIND ALL CODE" ///////////////////////////////////////////////////////////
MsgBox "done"
End Sub[/code]