I'm totally lost

Welp75

New Member
Joined
Apr 26, 2013
Messages
9
Hello,

I'm wondering if there's anybody who has encountered this same issue.
I'm building a simple tool for data registration. I have designed my user forms and build them in Excel 2010 using the VBE.
During testing I noticed I forget to do a check when entering a new userID, to make sure there are no double userID's.
I figured I could do the check with a VLookup. I entered the code and run it. Got an 1004 error, and examined my code to see if I made an error.

I noticed something odd. Whenever I assign a variable, the Variabletype displays with a Capitol (vb: Dim test As String), however this was not the case for the added range variable (Dim r As range). I tried to change this but it kept returning to lowercase. This only happens with the range variable. When trying this in a new file, it doesn't, so it must be something with the existing file, but I be ****ed if I know what has happened. Any other variable type can be added without this issue.

I'm not sure if this would be a problem in execution of the code, but the code does work in another file (from which I actually copied it), so I'm led to believe it is an issue...

Any thoughts on this?

Thanks in advance!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

oldbrewer

Well-known Member
Joined
Apr 11, 2010
Messages
11,005
try dim rx as range and adjust your other lines of code accordingly
 

Welp75

New Member
Joined
Apr 26, 2013
Messages
9
try dim rx as range and adjust your other lines of code accordingly

Hi oldbrewer,

Tried as you suggested, but no effect. I have tried different names, but each time the same happens: it looks like Excel is not recognizing the Range variable in this file. Since it works in other files (existing and new) I led to believe there is something wrong with the file I'm working with. I have duplicated the work into a new file and it is working now, so my problem is solved, but I still find it odd and cannot explain why this has happened.

Nevertheless I thank you for trying to help :)

Best regards,
Paul
 

Kyle123

Well-known Member
Joined
Jan 24, 2012
Messages
2,715
Do you have a variable named range somewhere else in your code? Something like
Code:
Dim range as Range
 

Welp75

New Member
Joined
Apr 26, 2013
Messages
9
Do you have a variable named range somewhere else in your code? Something like
Code:
Dim range as Range

Hello Kyle123,

Sorry for the late reply. I have been enjoying a few days off :)

I checked the code to make sure, but this is not the case. One of the lessons learned from programming classes in the past (learning TurboPascal 7.0 which was the lastest version, so it has been quite a while ago :) ), is to never use reserved or registered names in my code.

Good suggestion though!

As stated before I have already copied the code into a new file and it works perfectly, so the problem is solved. I can live with the fact that I never know why this particular file showed this behavior :)

Best regards,
Paul
 

Forum statistics

Threads
1,137,296
Messages
5,680,672
Members
419,924
Latest member
Dhamodharan992

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
Top