Few Questions

dcharland

New Member
Joined
Mar 2, 2011
Messages
40
Hello,

I have a few questions with regards to VBA coding,

1) In my code I evaluate the "Yes" or "No" answers based on user input in cells (many of them) and when I read that value in VBA it's case sensitive. So "Yes" is not "yes". What is the best way to deal with this situation?
here is one of the line of code
HTML:
If Cells(4, "E").Value = "Yes" And Cells(11, "J").Value = "Yes" Then
2) I'm asking user to input a file path & filename in cell C5 (and 4 other cells) e.i. (C:\Users\work\temp.txt), that in it's self isn't a problem, but would like to have the user "browse" to find the file is that possible? If yes any ideas on how to implement it?

Also is there a way to verify if the file exist (assuming there is also the option for the user to actually type the file name)

Thanks for your help.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hello,

Welcome to the Board!

To handle case sensitivity (Thanks HotPepper):

<font face=Courier New><SPAN style="color:#00007F">If</SPAN> UCase(Cells(4, "E").Value) = "YES" And UCase(Cells(11, "J").Value) = "YES" <SPAN style="color:#00007F">Then</SPAN><br>        </FONT>
 
Upvote 0
For #2 have look at:

Application.GetOpenFilename("Text Files (*.txt), *.txt")

Code:
Function FileExists(ByVal strPath As String) As Boolean
'Function returns true if file exists, false otherwise
    If Dir(strPath) > "" Then
        FileExists = True
    Else
        FileExists = False
    End If
End Function
 
Last edited:
Upvote 0
thanks for the responses. I've implemented the ucase, but will do the other tomorrow as i have been working on this code for to long and my eyes aren't seing things properly anymore :eeek:
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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