dj44
06-22-2018, 02:52 AM
Good day,
i am investigating something to do with substitute.
I wanted to see if this is possible
How may i randomly substitute a XX in a cell with a choice from the offset column
Sub Substitute_words()
Dim oCell As Range
Dim i As Long
Dim vOffset As Variant, vSearch As Variant
vSearch = Array("XX", "YY")
vOffset = Array(2, 3) ' Offset Columns
For i = LBound(vSearch) To UBound(vSearch)
For Each oCell In ThisWorkbook.Worksheets("Test").Range("A2:A4").Cells
Call oCell.Replace(vSearch(i), oCell.Offset(, vOffset(i)).Value, xlPart)
Next oCell
Next i
End Sub
Column A.__________________Column B - Choices
Hello XX___________________Dan| Zoe | Alex
Nice YY___________________Car | Train | Bus
how may i randomly substitute XX or YY with a value from its offset
After
Column A
Hello Dan
Nice Train
would this be possible?
I guess im trying to create some random phrases
I wanted to know how to select a value from the possible values and put that in my XX
Something to do with an random formula i guess
i am investigating something to do with substitute.
I wanted to see if this is possible
How may i randomly substitute a XX in a cell with a choice from the offset column
Sub Substitute_words()
Dim oCell As Range
Dim i As Long
Dim vOffset As Variant, vSearch As Variant
vSearch = Array("XX", "YY")
vOffset = Array(2, 3) ' Offset Columns
For i = LBound(vSearch) To UBound(vSearch)
For Each oCell In ThisWorkbook.Worksheets("Test").Range("A2:A4").Cells
Call oCell.Replace(vSearch(i), oCell.Offset(, vOffset(i)).Value, xlPart)
Next oCell
Next i
End Sub
Column A.__________________Column B - Choices
Hello XX___________________Dan| Zoe | Alex
Nice YY___________________Car | Train | Bus
how may i randomly substitute XX or YY with a value from its offset
After
Column A
Hello Dan
Nice Train
would this be possible?
I guess im trying to create some random phrases
I wanted to know how to select a value from the possible values and put that in my XX
Something to do with an random formula i guess