SirSchiz
New Member
- Joined
- May 4, 2011
- Messages
- 24
Any help is so much appreciated with this! My VBA Skills are offically Strained!
I have many worksheets that have a data structure like this:
Sample Data for testing:
BTW..All Data in all worksheets is in Column A
I need the the first found X1 to the Next Found X1 copied over to column D and combined(Concatenate right?) into 1 cell. Then repeated, but the next section would copy and combine to the next cell available in column D each section separated by a empty cell until all sections are complete. Then Next worksheet. The code I have so far copies only the first found section and copies, but very poorly combines into one cell.
My Sad Code:
I have many worksheets that have a data structure like this:
Sample Data for testing:
Code:
X1
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
X1
ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
ppppppppppppppppppp
X1
ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
ppppppppppppppppp
X1
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
pppppppppppppppppppppppp
X1
ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
BTW..All Data in all worksheets is in Column A
I need the the first found X1 to the Next Found X1 copied over to column D and combined(Concatenate right?) into 1 cell. Then repeated, but the next section would copy and combine to the next cell available in column D each section separated by a empty cell until all sections are complete. Then Next worksheet. The code I have so far copies only the first found section and copies, but very poorly combines into one cell.
My Sad Code:
Code:
Sub FindIt()
Dim Term As String
Dim Var As Range
Dim NxWsht As Worksheet
Dim WkBk As Workbook
Term = "X1"
Set Var = Range("A:A").Find(What:=Term, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
Set WkBk = ActiveWorkbook
For Each NxWsht In WkBk.Sheets
ActiveSheet.Range(Var, Var.End(xlUp)).Select
With Selection
.Copy
.Range("D:D").PasteSpecial xlValues
End With
Set rng = Selection
Set cel = Cells.Value
For Each cel In rng
x = x & cel.Value
Next
ActiveSheet.Range("D:D").Value = x
Set Var = Range("A:A").FindNext([A1])
Next NxWsht
End Sub