![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 160
|
Good Morning All,
I am trying to remove a line if a cell is a certain colour (in this case, yellow). This is the code I thought I'd use, but it doesn't seem to like it. Set JerWB = Workbooks("Test.xls").Worksheets("use") rr = 1 If (JerWB.Cells(rr, 1).ColorIndex = 6) Then JerWB.Cells(rr, 1).EntireRow.Delete Shift:=xlShiftUp Else rr = rr + 1 End If |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Apr 2002
Location: Vancouver BC , Canada
Posts: 6,259
|
Are you sure you only want to increment your loop counter when there is no yellow color ?
You probably want to have rr=rr+1 outside of the if statement |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Apr 2002
Location: Vancouver BC , Canada
Posts: 6,259
|
Code:
Set JerWB = Workbooks("Test.xls").Worksheets("use")
do
rr = rr +1
If (JerWB.Cells(rr, 1).ColorIndex = 6) Then
JerWB.Cells(rr, 1).EntireRow.Delete Shift:=xlShiftUp
End If
loop until(JerWB.Cells(rr, 1).value = ""
NOTE: Testing performed on Win2K utilizing Office 2000. Solutions may need tweaking for other versions. [ This Message was edited by: Nimrod on 2002-05-13 01:58 ] |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Mar 2002
Posts: 160
|
No luck with that Nimrod.
Run Time error 438: Object doesn't support this property or method. |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Hi Ben
This appears to work...
Tom P.S. If the Font color is what you are after then replace the property "Interior" with the object "Font" [ This Message was edited by: TsTom on 2002-05-13 03:14 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|