SOLVED

Trying to assign Range.Offset to a variable

Brass Contributor

How do I assign Range.Offset to a variable?

 

 

Dim x As Range: x = rng.Offset(0,-1)

x.ClearContents

 

I'm getting Object required error message

 

2 Replies
best response confirmed by rodsan724 (Brass Contributor)
Solution

@rodsan724 

You must use the keyword Set to assign an object:

 

Set x = rng.Offset(0, -1)

 

By the way, didn't you want

 

x.ClearContents

Thanks, I fixed in OP
1 best response

Accepted Solutions
best response confirmed by rodsan724 (Brass Contributor)
Solution

@rodsan724 

You must use the keyword Set to assign an object:

 

Set x = rng.Offset(0, -1)

 

By the way, didn't you want

 

x.ClearContents

View solution in original post