danielpalfrey
New Member
- Joined
- Nov 21, 2018
- Messages
- 17
Ok, this is a little unusual, I need to find cells that contain one of multiple words.
The plan is, double click a word in column A, upon clicking this word a list will be searched to find out if the word appears in the list, if it does appear in the list then the hidden rows below need to be unhidden untill the next recognised word in the list. I have it working somewhat, but when running the debug it doesnt do as I would expect it to in terms of used values, even though the end result works.
My code is:
Now, I have no idea how this code is working, I am hoping someone could let me know where I went wrong.
Originally, when I made this I programmed each sup with its own bar of code to the next sup, this was not practical as I could not add to the list easily and wanted to limit the amount of code needed to add a new sup
I have also added a simple button to hide all cells not containing the words in lst I am having some problems getting this working though, I am sure however that if someone could correct what I have done above I should be able to then get the code working to hide them,
Many Many thanks
Dan
The plan is, double click a word in column A, upon clicking this word a list will be searched to find out if the word appears in the list, if it does appear in the list then the hidden rows below need to be unhidden untill the next recognised word in the list. I have it working somewhat, but when running the debug it doesnt do as I would expect it to in terms of used values, even though the end result works.
My code is:
Code:
Dim hre As StringDim WrdArray() As String
Dim FindText As String
Dim Onecell As Range
hre = ActiveCell.Row + 1
lst = "one/two/three/four/five/six/seven/eight/nine/ten"
If Not Intersect(Target, Range("A1:A5000")) Is Nothing Then
For Each Onecell In Range("A" & hre & ":A46")
WrdArray() = Split(lst, "/")
If InStr(Onecell.Text, FindText) > 0 Then
ListText = Onecell.Row - 1
FindText = WrdArray(i)
End If
Next Onecell
Rows(hre & ":" & ListText).Hidden = Not Rows(hre & ":" & ListText).Hidden
If MsgBox(Prompt:="Open address label?", Buttons:=vbYesNo + vbQuestion, Title:="Hyperlink Activated") = vbYes Then
Dim objWord As Object
Dim fl As String
fl = ActiveCell.Text
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.Documents.Open "C:\Users\700warranty\Desktop\DOCUMENTS\Address Labels\" & fl & ".docx"
Now, I have no idea how this code is working, I am hoping someone could let me know where I went wrong.
Originally, when I made this I programmed each sup with its own bar of code to the next sup, this was not practical as I could not add to the list easily and wanted to limit the amount of code needed to add a new sup
I have also added a simple button to hide all cells not containing the words in lst I am having some problems getting this working though, I am sure however that if someone could correct what I have done above I should be able to then get the code working to hide them,
Many Many thanks
Dan