Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In accordance with good practice, I'm trying to rewrite sections of my code
that rely on first selecting cells to remove the selection part. Generally I've had good success with this, but the following has me totally stumped. I have a series of subs for formatting text along the lines of the example below: Sub format_over_105(myRange As Range) With myRange.Font .ThemeColor = xlThemeColorDark1 .TintAndShade = 0 End With With myRange.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .Color = 255 .TintAndShade = 0 .PatternTintAndShade = 0 End With End Sub The original code used the formatter like this: Range("C1").Select Selection.Value = " 105%" format_over_105 (Selection.Cells) It seemed that I should be able to change this to: Range("C1").Value = " 105%" format_over_105 (Range("C1").Cells) However, the second example gives the error 'Object Required' on the second line, and when I hold the mouse over the line that gave the error, it tells me Range("C2").Cells = "Delivery 105%". I have tried using just Range("C1"), but that gives the same error. I would have thought that the first and second example were equivalent - can anyone explain to me why the first works and the second doesn't? The purpose of the above is simply to provide a 'key' - the formatting of the actual rows according to their values works fine with For Each myRow In ActiveSheet.UsedRange.Rows .... format_over_105 (myRow.Cells) Many thanks in advance, Tara H |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Strange if(***) behaviour? | Excel Discussion (Misc queries) | |||
Strange "FormatCells" behaviour | Excel Worksheet Functions | |||
Strange behaviour in VBA Help | Excel Programming | |||
Strange or error : For each cl in Selection 'cl as range | Excel Programming | |||
strange behaviour | Excel Programming |