Named Range, Strange VBA thingy too

Engineer Joe

Well-known Member
Joined
Jun 10, 2005
Messages
549
I have two Problems:

1. In my code, I search for ranges containing identifying text and label them (BodyStart and BodyEnd) like this.
Code:
Set BodyStart = Cells.Find(what:="General", searchorder:=xlByRows, searchformat:=False)

Then I try to name all of the cells between BodyStart and BodyEnd. I've selected the name BodyEntire. Like this...

Code:
Set BodyEntire = range(range("BodyStart"), range("BodyEnd"))

But with the above line of code, i always get the dreaded error 1004 - Method 'range' of object '_global' failed.

Am I naming the range incorrectly?

2. Also, shouldn't the " r " in range be automatically capitalized for all of this crap? I don't know why " r " is not capitalized, but that isn't disturbing the program, because it works everywhere else with the lower case...
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Joe

The reason for the error is because you are trying to use BodyStart as a named range. It isn't a named range, it's a range object.

Does this work?
Code:
Set BodyEntire = Range(BodyStart, BodyEnd)
 
Upvote 0
Thanks Norie...yeah, I shoulda seen it. It's just been a good long time since i've screwed with VBA. Got any ideas about why is giving me the lower case "r" in range???
 
Upvote 0
Joe

Do you have a variable called range?
 
Upvote 0
Actually, that's the first thing that I looked for...and I don't have one called "range". If i did, wouldn't it really screw up every code in every module for which the variable was operable???

Could it have something to do with my plugins? I loaded some utilities into my vba editor from this sight. That wouldn't do it would it?
 
Upvote 0
The only way I was able to simulate your problem was by declaring a variable called range.

Where is this happening? Is it every instance of range?
 
Upvote 0
Norie,

It appears that it happens for every occurence of "range" for every module in My Personal Workbook. However, upon looking at other excel workbooks that have their own isolated modules, I found that Range was capitalized. The plot thickens.
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,442
Members
448,898
Latest member
drewmorgan128

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top