Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / January 2008

Tip: Looking for answers? Try searching our database.

Conditional Formatting with UsedRange Property for each Worksheet

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RyanH - 11 Jan 2008 20:00 GMT
I am getting an error indicated below in my code (Application-defined or
object-defined Error,  Run-Time Error '1004').  I want to have a bottome
border line every 5 lines.  Can someone explain to me why this portion of
code will not work?  Huge THANKS in advanced!!!

Sub JobTracker1()

Application.ScreenUpdating = False

Call shUnProtect

RowCount = 3

With Sheets("Archive")
   Do While .Range("L" & RowCount) <> ""
       myMonth = Format(.Range("L" & RowCount), "mmmm")
       Application.StatusBar = "Moving Sales Orders from Archive to " &
myMonth & "...Please Wait."
       With Sheets(myMonth)
           If IsEmpty(.Range("A3")) = True Then
               Sheets("Archive").Range("A" & RowCount & ":P" & RowCount).Cut
               .Paste Destination:=.Range("A3")
               Sheets("Archive").Range("Q" & RowCount & ":BO" & RowCount).Cut
               .Paste Destination:=.Range("T3")
           Else
               LastRow = .Range("A" & Rows.Count).End(xlUp).Row
               NewRow = LastRow + 1
               Sheets("Archive").Range("A" & RowCount & ":P" & RowCount).Cut
               .Paste Destination:=.Range("A" & NewRow)
               Sheets("Archive").Range("Q" & RowCount & ":BO" & RowCount).Cut
               .Paste Destination:=.Range("T" & NewRow)
           End If
           With .Cells
               .Interior.ColorIndex = 41
               .Font.ColorIndex = 2
           End With
           .UsedRange.FormatConditions.Add Type:=xlExpression,
Formula1:="=MOD(ROW(),5)=0"   <==ERROR ERROR ERROR
           With .UsedRange.FormatConditions(1).Borders(xlBottom)
               .LineStyle = xlContinuous
               .Weight = xlThin
               .ColorIndex = xlAutomatic
           End With
       End With
       RowCount = RowCount + 1
   Loop
End With
       
Application.StatusBar = False
Application.CutCopyMode = False
Application.ScreenUpdating = False

Call shProtect

End Sub
Bob Phillips - 11 Jan 2008 22:06 GMT
I haven't examined the code in detail, but as you through each cell but
setting the whole Usedrange, I think you are trying to add a 4th condition.
If you step through, you can verify this or not.

Signature

---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

>I am getting an error indicated below in my code (Application-defined or
> object-defined Error,  Run-Time Error '1004').  I want to have a bottome
[quoted text clipped - 55 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.