BAKELOVEMORE
New Member
- Joined
- Apr 2, 2024
- Messages
- 13
- Office Version
- 365
- Platform
- Windows
I have the following Selection.Replace code that I have used in other subs but I cannot figure out how to capture the cell contents from a formula and pass it to Selection.
I have used Range(activeRow,"H").copy and Selection.copy and passing formula to another variable. I have used .text in all kinds of ways and nothing changes to the string when I run the sub.
I also have tried other ways to join the text including Range((activeRow, "E") , (activeRow, "G")).select.
It does not error, I just do not get the replacement. Thanks for any help you can give me. I assume it is easy but I have searched and tried everything I can think of.
I have used Range(activeRow,"H").copy and Selection.copy and passing formula to another variable. I have used .text in all kinds of ways and nothing changes to the string when I run the sub.
I also have tried other ways to join the text including Range((activeRow, "E") , (activeRow, "G")).select.
It does not error, I just do not get the replacement. Thanks for any help you can give me. I assume it is easy but I have searched and tried everything I can think of.
VBA Code:
Sub GetStnProbs()
Application.ScreenUpdating = False
Const SubName As String = "GetStnProbs"
Const SheetName As String = "OBSERVATIONS"
If ActiveSheet.Name <> SheetName Then
MsgBox "This macro can only be called from '" & SheetName & "'", vbOKOnly, SubName
Exit Sub
End If
Dim activeRow As Long
Dim formula As String
Dim ActiveCell2 As Range
activeRow = ActiveCell.Row
formula = "=TEXTJOIN({"" & ""},TRUE,FILTER('STATION LIST'!$E$2:$G$66,'STATION LIST'!$C$2:$C$66 = E" & activeRow & "))"
ActiveSheet.Cells(activeRow, "H").formula = formula
ActiveCell = ActiveSheet.Cells(activeRow, "H")
ActiveCell.Activate
Set ActiveCell2 = ActiveCell
Selection.Copy
Selection.Replace What:="OOF", Replacement:="OUT OF FOCUS ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Clipboard ActiveCell
Range("H65").PasteSpecial
ActiveCell2.Activate
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub