NDetwiler44
New Member
- Joined
- May 11, 2019
- Messages
- 1
I've imported an XML file into excel but it did not input that neatly and am now trying to extract the data out that I need. There are a number of department in the data with performance ratings. The number of departments is not always the same and the number of performance ratings is never the same (each department has different category ratings). I have figured out how to search for the text "Supervisor:" and store each cell location into an array (see code). The code highlights the cells in the array only for test purposes. I would now like to copy all the cells between these locations including to first cell into different columns on another worksheet (call it Data). From here I believe I can sort the data even more but would just like help to the next step for now.
All data I need from the XML does copy into 1 column (CF).
Thank you for the help. I do believe I got the code above from this forum.
All data I need from the XML does copy into 1 column (CF).
Code:
Sub HighlightFindValues()
'PURPOSE: Highlight all cells containing a specified values
'SOURCE: www.TheSpreadsheetGuru.com
Dim fnd As String, FirstFound As String
Dim FoundCell As Range, rng As Range
Dim myRange As Range, LastCell As Range
'What value do you want to find (must be in string form)?
fnd = "Supervisor:"
Set myRange = ActiveSheet.UsedRange
Set LastCell = myRange.Cells(myRange.Cells.Count)
Set FoundCell = myRange.Find(what:=fnd, after:=LastCell)
'Test to see if anything was found
If Not FoundCell Is Nothing Then
FirstFound = FoundCell.Address
Else
GoTo NothingFound
End If
Set rng = FoundCell
'Loop until cycled through all unique finds
Do Until FoundCell Is Nothing
'Find next cell with fnd value
Set FoundCell = myRange.FindNext(after:=FoundCell)
'Add found cell to rng range variable
Set rng = Union(rng, FoundCell)
'Test to see if cycled through to first found cell
If FoundCell.Address = FirstFound Then Exit Do
Loop
'Highlight Found cells yellow
rng.Interior.Color = RGB(0, 255, 255)
Exit Sub
'Error Handler
NothingFound:
MsgBox "No values were found in this worksheet"
End Sub
Thank you for the help. I do believe I got the code above from this forum.