Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Jun 28, 1:04 pm, Steve the large
wrote: thats because the following line tempDay = Day(Cells(lngRow, 2).Value) should be tempDay = Day(wks.Cells(lngRow, 2).Value) without the "wks." the Cells() property is referring, correctly, to the currently active sheet, which doesn't change just because wks does. "Idgarad" wrote: On Jun 27, 2:38 pm, Steve the large wrote: Oops, did not read your whole post, sorry. There are several problems with the code you have listed -it can't work as written. (1) tempday is used before it has a value assigned. (2) you have column 1 being used to get the day from, it should be column 2 I corrected these errors, and ran the code with the data you provided copied into sheet1, sheet2, & sheet3 and it worked for all sheets. Here is the code I ran: Sub Hilite() Dim lngRow As Long Application.ScreenUpdating = False For Each wks In Worksheets lngRow = wks.Range("A2").End(xlDown).Row Do While lngRow 0 tempDay = Day(Cells(lngRow, 2).Value) If Not IsEmpty(tempDay) Then If tempDay Mod 2 = 0 Then wks.Rows(lngRow).Interior.ColorIndex = 37 Else wks.Rows(lngRow).Interior.ColorIndex = 36 End If End If lngRow = lngRow - 1 Loop Next Application.ScreenUpdating = True End Sub Try using the debugger and breaking on the first line, then step through the code using the "F8" key. But it should work. "Idgarad" wrote: The following is my attempt to color even days 1 color and odd days another color. Sub Hilite() Dim lngRow As Long Application.ScreenUpdating = False For Each wks In Worksheets lngRow = wks.Range("A2").End(xlDown).Row Do While lngRow 0 If Not IsEmpty(tempDay) Then tempDay = Day(Cells(lngRow, 1).Value) If tempDay Mod 2 = 0 Then wks.Rows(lngRow).Interior.ColorIndex = 37 Else wks.Rows(lngRow).Interior.ColorIndex = 36 End If End If lngRow = lngRow - 1 Loop Next Application.ScreenUpdating = True End Sub The problem is it works but applies the formatting to only the first tab. What am I missing here? Sample data below copied across 7 worksheets: -sdfgsdfg 6/17/2007 19:43:22 6/17/2007 19:45:25 sdfgsdfg 6/17/2007 22:07:45 6/17/2007 22:08:19 fghjfgj 6/17/2007 22:15:04 6/17/2007 22:15:25 rtuyru 6/18/2007 4:00:09 6/18/2007 4:12:37 ryjyr 6/18/2007 4:31:51 6/18/2007 4:43:49 vbngh 6/18/2007 19:00:44 6/18/2007 19:01:16 vhnvhn 6/18/2007 19:07:37 6/18/2007 19:07:57 vmhvmv 6/19/2007 4:00:06 6/19/2007 4:13:02 dhgdtr 6/19/2007 4:33:16 6/19/2007 4:45:13 nmfyy 6/19/2007 19:01:09 6/19/2007 19:01:45 dthdth 6/19/2007 19:09:11 6/19/2007 19:09:32 dthdg 6/20/2007 4:00:07 6/20/2007 4:13:35 cvhncnb 6/20/2007 4:38:32 6/20/2007 4:50:31 cnccg 6/20/2007 19:00:56 6/20/2007 19:01:49 cgnct 6/20/2007 19:09:44 6/20/2007 19:10:05 cntctnctn 6/21/2007 4:00:11 6/21/2007 4:16:25 cntctnct 6/21/2007 4:44:37 6/21/2007 4:56:37 5yd5hh 6/21/2007 19:00:56 6/21/2007 19:01:44 d5hdg 6/21/2007 19:11:37 6/21/2007 19:11:58 dngdnd 6/22/2007 4:00:11 6/22/2007 4:14:19 cngcn 6/22/2007 4:57:18 6/22/2007 5:09:22 ccgncg 6/22/2007 19:00:52 6/22/2007 19:01:29 dth5 6/22/2007 19:08:21 6/22/2007 19:08:41 dh5dhd 6/23/2007 21:00:06 6/23/2007 21:12:18- Hide quoted text - - Show quoted text - Well that sort of works but now here is the problem. Change the other tabs dates around and all that is happening is the coloring is being based off the first sheet only. So the highlighting is correct on the first tab but all the other tabs are wrong if the data isn't an exact match of the first tab.- Hide quoted text - - Show quoted text - Fixed and working great. Thank you, the help is greatly appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Apply to all worksheets | Excel Discussion (Misc queries) | |||
apply arithmetic functions on special multiple cells | Excel Worksheet Functions | |||
Won't apply to all worksheets | Setting up and Configuration of Excel | |||
Find the nearest point to 1000 rows where "amounts" balance and apply special formatting to that row | Excel Programming | |||
How does special formula apply to conditional formatting? | Excel Discussion (Misc queries) |