Slamdunkromeo
New Member
- Joined
- Sep 20, 2011
- Messages
- 5
Hi,
I am trying to merge cells in a row, based on the cell color using VBA.
Example:
A1 = Green
B1 = Green
C1 = Green
D1 = Blanco
E1 = blanco
F1 = Pink
G1 = Pink
etc..
I would like the cells A1:C1 merged. Skip D1:E1. And Merge F1:G1
The cell and the colors are not fixed, so the merge macro should be flexibel.
Second, i would like to place a value in the merged cell (again flexibel position as above) and input the merged cell with a kind of VLOOKUP ( lookup value is one cell below the merged cell. Lookup tabel is a fixed location)
for the first part 1st tried this macro:
Sub Macro2merge()
'
' Macro2merge Macro
'
For Each cell In Range("A1:O1")
Select Case cell.Interior.ColorIndex
Case Is = 4
Selection.Merge
Case Is = 7
Selection.Merge
End Select
Next cell
End Sub
By the definition of the Range, the macro merges all cell A1:O1 into one cell.
Looking forward to receive any help on this.
I am trying to merge cells in a row, based on the cell color using VBA.
Example:
A1 = Green
B1 = Green
C1 = Green
D1 = Blanco
E1 = blanco
F1 = Pink
G1 = Pink
etc..
I would like the cells A1:C1 merged. Skip D1:E1. And Merge F1:G1
The cell and the colors are not fixed, so the merge macro should be flexibel.
Second, i would like to place a value in the merged cell (again flexibel position as above) and input the merged cell with a kind of VLOOKUP ( lookup value is one cell below the merged cell. Lookup tabel is a fixed location)
for the first part 1st tried this macro:
Sub Macro2merge()
'
' Macro2merge Macro
'
For Each cell In Range("A1:O1")
Select Case cell.Interior.ColorIndex
Case Is = 4
Selection.Merge
Case Is = 7
Selection.Merge
End Select
Next cell
End Sub
By the definition of the Range, the macro merges all cell A1:O1 into one cell.
Looking forward to receive any help on this.