sweetness34
Board Regular
- Joined
- Jun 23, 2011
- Messages
- 70
Hi
I need some help with code to distinguish a range of cells that have a specific word. The problem is that word is within another word. For example I have a variation of the words "SandBox", "Box", and "Wood" all in one column. I need to find the cells that have the word "Box" and not "SandBox". Right now the code I have wont exclude "SandBox". This is what I have:
How can I modify this to only find "Box".
Thanks
I need some help with code to distinguish a range of cells that have a specific word. The problem is that word is within another word. For example I have a variation of the words "SandBox", "Box", and "Wood" all in one column. I need to find the cells that have the word "Box" and not "SandBox". Right now the code I have wont exclude "SandBox". This is what I have:
Code:
Dim x As String
Dim y As String
Dim z As String
Cells.Find(What:="Box", After:=Range("A1"), SearchDirection:=xlNext).Select
x = Selection.Offset(0, 4).Address
Cells.Find(What:="Box", After:=Range("A1"), SearchDirection:=xlPrevious).Select
y = Selection.Offset(0, 4).Address
z = Selection.Offset(1, 5).Address
ActiveWorkbook.Worksheets("Sheet1").Range(z).Select
Selection.Value = Application.WorksheetFunction.Sum(Range(x, y))
How can I modify this to only find "Box".
Thanks