marlonsaveri
Board Regular
- Joined
- Jan 28, 2011
- Messages
- 68
Hi, I need find some word, for example, ABC in each sheet; then, create a new row to put new values. However, in column A, we have merged cells, for example:
(I will dots to symbolize the merged cells)
......|123|123|123
......|123|123|123
ABC|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123
EFG|123|123|123
......|123|123|123
......|123|123|123
Then, a code need make:
......|123|123|123
......|123|123|123
ABC|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123 (newline)
......|123|123|123
......|123|123|123
EFG|123|123|123
......|123|123|123
......|123|123|123
So I tried use that code to do it
But it's doing:
......|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123 (newline)
ABC|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123
or
......|123|123|123
......|123|123|123
ABC|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123 (newline)
......|123|123|123
......|123|123|123
EFG|123|123|123
......|123|123|123
......|123|123|123
What's wrong?
(I will dots to symbolize the merged cells)
......|123|123|123
......|123|123|123
ABC|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123
EFG|123|123|123
......|123|123|123
......|123|123|123
Then, a code need make:
......|123|123|123
......|123|123|123
ABC|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123 (newline)
......|123|123|123
......|123|123|123
EFG|123|123|123
......|123|123|123
......|123|123|123
So I tried use that code to do it
Code:
tipo = "ABC"
For i = 2 To Sheets.Count
Set busca = Worksheets(i).Cells.Find(what:=tipo, after:=Range("A1"), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not busca Is Nothing Then
Cells(busca.MergeArea(busca.MergeArea.Count).Row + 1, busca.Column).EntireRow.Insert
Set intervalo = Union(busca.MergeArea, busca.MergeArea(busca.MergeArea.Count).Offset(1, 0))
Application.DisplayAlerts = False
intervalo.Merge
Application.DisplayAlerts = True
busca.MergeArea(busca.MergeArea.Count).Offset(0, 1).FormulaR1C1 = TextBox1.Text
......|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123 (newline)
ABC|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123
or
......|123|123|123
......|123|123|123
ABC|123|123|123
......|123|123|123
......|123|123|123
......|123|123|123 (newline)
......|123|123|123
......|123|123|123
EFG|123|123|123
......|123|123|123
......|123|123|123
What's wrong?