elmnas
02-25-2015, 02:37 AM
Hi guys,
I have problem,
I need to find out which column the cell is in,
the name of the column is always on the first row,
then copy the first cell in the column + the founded cell into a new sheet,
on same place.
I have got this code to loop through all sheets also the cells,
and the code tells me which row the cell is but not the column,
See code below:
Sub my_for_loop3()
For Each sht In ActiveWorkbook.Worksheets
'MsgBox sht.Name
Set Rng = sht.UsedRange
For Each ColorCellID In Rng
If ColorCellID.Interior.ColorIndex = 23 Then
'MsgBox "Value Found in Cell " & Colorcell.Address & _
'" and the Cell Column Number is " & Colorcell.Column
MsgBox "the cell row is " & ColorCellID.Row
MsgBox "cellen är have column" (and some code)
End If
' Colorcell.Interior.ColorIndex = 45
' MsgBox "färgen finns inte"
Next
Next sht
End Sub
Could someone help me ?
Thank you in advance
I have problem,
I need to find out which column the cell is in,
the name of the column is always on the first row,
then copy the first cell in the column + the founded cell into a new sheet,
on same place.
I have got this code to loop through all sheets also the cells,
and the code tells me which row the cell is but not the column,
See code below:
Sub my_for_loop3()
For Each sht In ActiveWorkbook.Worksheets
'MsgBox sht.Name
Set Rng = sht.UsedRange
For Each ColorCellID In Rng
If ColorCellID.Interior.ColorIndex = 23 Then
'MsgBox "Value Found in Cell " & Colorcell.Address & _
'" and the Cell Column Number is " & Colorcell.Column
MsgBox "the cell row is " & ColorCellID.Row
MsgBox "cellen är have column" (and some code)
End If
' Colorcell.Interior.ColorIndex = 45
' MsgBox "färgen finns inte"
Next
Next sht
End Sub
Could someone help me ?
Thank you in advance