mid string function

Boris7265

Board Regular
Joined
Apr 6, 2011
Messages
68
Hello,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
I need help with this code below. The code is extracting 4 last strings of the name of the file that is being uploaded and names it to new just added worksheet. The code doesn’t work and Excel debugs it as “Compile error:Expected array” in the "Find"
<o:p> </o:p>
Dim FileName2 As String<o:p></o:p>
Dim Filename1 As String<o:p></o:p>
Dim Filename As String<o:p></o:p>
Dim FLName As String<o:p></o:p>
FLName = Application.GetOpenFilename<o:p></o:p>
Dim NewSheet As Worksheet<o:p></o:p>
Filename1 = Right(FLName, 12)<o:p></o:p>
FileName2 = Mid(Filename1, Find(".", Filename1) + 1, 4)<o:p></o:p>
Worksheets.Add().Name = FileName2<o:p></o:p>
Set NewSheet = ActiveSheet
<o:p> </o:p>
<o:p> </o:p>
I am not sure what it is about .The code seems correct.
<o:p> </o:p>
Any suggestions will be greatly appreciated
<o:p> </o:p>
The Best Regards,
<o:p> </o:p>
BorisGomel
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Try replacing with

Rich (BB code):
FileName2 = Mid(Filename1, InStr(Filename1,".") + 1, 4)
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

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