ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help on coercing a range (https://www.excelbanter.com/excel-programming/437414-help-coercing-range.html)

rick

Help on coercing a range
 
I have a problem with trying to get a range specified the way a subroutine
wants it.

I am trying to .clearcontents of a range in a sheet. Here is the code:
' clear the explainations
Application.Goto reference:="ABC_" & Group_Name & "_Start"
Set StartRange = ActiveCell
' *** function LastRow returns the row number as long
lngEndRow = LastRow
Set EndRange = StartRange.Offset(lngEndRow - StartRange.Row, 0)

Here is the problem. I am getting: an Error 91 Object variable or with block
variable not set.
I am trying to pass the Find_Range function "$A$10:$A$137"
immediate shows that StartRange.address is "$A$10" and the endrange is
"$A$137" (but maybe the quotes really aren't there but show in the
Immediate.

Find_Range("Explainations", Range(StartRange.Address & ":" &
EndRange.Address)).Select
ActiveCell.Offset(1, 0).Select
Selection.ClearContents

Can you please tell me how to do this? Thanks,

rick


rick

Help on coercing a range
 
Sorry group, I found the error. I spelled Explanations wrong. The Range
structures are fine.

.... rick
"rick" wrote in message
...
I have a problem with trying to get a range specified the way a subroutine
wants it.

I am trying to .clearcontents of a range in a sheet. Here is the code:
' clear the explainations
Application.Goto reference:="ABC_" & Group_Name & "_Start"
Set StartRange = ActiveCell
' *** function LastRow returns the row number as long
lngEndRow = LastRow
Set EndRange = StartRange.Offset(lngEndRow - StartRange.Row, 0)

Here is the problem. I am getting: an Error 91 Object variable or with
block variable not set.
I am trying to pass the Find_Range function "$A$10:$A$137"
immediate shows that StartRange.address is "$A$10" and the endrange is
"$A$137" (but maybe the quotes really aren't there but show in the
Immediate.

Find_Range("Explainations", Range(StartRange.Address & ":" &
EndRange.Address)).Select
ActiveCell.Offset(1, 0).Select
Selection.ClearContents

Can you please tell me how to do this? Thanks,

rick




All times are GMT +1. The time now is 03:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com