PDA

View Full Version : Syntax Help



keentolearn
10-22-2008, 03:37 AM
Hi,


LR = ActiveSheet.Range("C" & Rows.Count).End(xlUp).Row

Range(D & LR & ":" & E & LR).Select
Selection.ThemeColor = xlThemeColorAccent1
For my sheet LR=2. With little knowledge I have, I thought that the above code will choose Range(D2:E2). But as I run macro it is saying

Run-time error '438':
Object doesn't supportthis property or method and Range(H15:I15) is being filled up with required color.

Can you please explain me what is this and what is the correct code to get required range i.e., D2:E2

Thank you.

mdmackillop
10-22-2008, 04:16 AM
You need quotes round the column letters. Also, no need to select.

Range("D" & LR & ":" & "E" & LR).ThemeColor = xlThemeColorAccent1
' or
Range("D" & LR).Resize(, 1).ThemeColor = xlThemeColorAccent1

Bob Phillips
10-22-2008, 04:20 AM
type



' or
Range("D" & LR).Resize(, 2).ThemeColor = xlThemeColorAccent1

keentolearn
10-22-2008, 05:22 AM
Hi xld & mdmackillop,

Sorry to say. The problem is still remaining.

I simply code as shown below.


Sub test()

Dim LR As Integer

LR = ActiveSheet.Range("C" & Rows.Count).End(xlUp).Row

Range("D" & LR).Resize(, 2).ThemeColor = xlThemeColorAccent1

End Sub