• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Change code without extensions

Hello dear helpers
I have this code
Code:
ActiveSheet.Range("B2") = ActiveWorkbook.Name
But I want it without the extention
Thanks in advance
 
Code:
ActiveSheet.Range("B2").Value2 = left$(activeworkbook.Name, instrrev(activeworkbook.Name, ".") - 1)
 
That is true. If that is a possibility, you'd need to test first:
Code:
Dim lDot as Long
lDot = instrrev(activeworkbook.Name, ".")
If lDot = 0 then
ActiveSheet.Range("B2").Value2 = activeworkbook.Name
else
ActiveSheet.Range("B2").Value2 = left$(activeworkbook.Name, lDot - 1)
End If
 
Back
Top