VBA StrFileName question

Katy Jordan

Well-known Member
Joined
Jun 28, 2008
Messages
596
Hi, the below line reads if the user has saved the Csv file in lowercase ".csv" but there is a chance they might save in uppercase, is there some kind of code that i could put into place which would cater for both scenarios?

strFileName = Range("rngRgPath") & ".csv"
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Katy

All that code is doing is setting a the value for a string variable.

Are you having problems later in the code when you try to use the variable to do something with a CSV file?
 
Upvote 0
Katy

All that code is doing is setting a the value for a string variable.

Are you having problems later in the code when you try to use the variable to do something with a CSV file?

i'm having no trouble with the code, but just being mindful that if the user saves the file as CSV rather than csv then the code would fail.
 
Upvote 0
Katy

If you are trying to open a file then the case of strFileName shouldn't be relevant.

Excel, and Windows as far as I know, won't allow you to use the same name twice even if the case is different.
 
Upvote 0
Katy

If you are trying to open a file then the case of strFileName shouldn't be relevant.

Excel, and Windows as far as I know, won't allow you to use the same name twice even if the case is different.

So if the code is .csv but the user saves the file as CSV then the code should still open the file?
 
Upvote 0
Katy

Yes, as far as I know there should be no problem.

If there is then perhaps there something else going wrong, or even something in your setup that does differentiate between case for filenames.
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,866
Members
452,948
Latest member
UsmanAli786

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