If I put FIND or SEARCH in my macro, I get "SUB or FUNCTION not defined"
Change search to Find, get the same error.Bookname = ActiveWorkbook.Name zz = Search(".", Bookname - 1)
SEARCH & FIND are worksheet functions, not VB functions. Check "Range.Find" in Help & "using Worksheet functions in VB"
---
Ben Van Johnson
I searched all of the help, only search and find in worksheet functions. Here is what I am trying to do. I want to get the active workbook name and call it Bookname. Then I want to delete the extension by finding the position of "." in the variable Bookname and save only the left characters to the "." less one.
Sub NoExtension() ' ' 'Save in xlsm format Bookname = ActiveWorkbook.Name 'Remove extension Bookname = Left(Bookname, 6) 'Really want 'Bookname = left(Bookname, Find(".",Bookname)-1) Application.DisplayAlerts = False 'Turn on next line to save file ActiveWorkbook.SaveAs Filename:=Bookname Application.DisplayAlerts = True Sheets(1).Name = Bookname End Sub
Option Explicit Sub NoExtension() 'I want to get the active workbook name and call it Bookname 'Then I want to delete the extension by finding the position of "." 'in the variable Bookname and save only the left characters to the "." less one. Dim BookName As String, _ DotPosition As Long BookName = ActiveWorkbook.Name DotPosition = InStr(BookName, ".") BookName = Mid(BookName, 1, DotPosition - 1) 'Save in xlsm format Application.DisplayAlerts = False 'Turn on next line to save file ActiveWorkbook.SaveAs Filename:=BookName Application.DisplayAlerts = True Sheets(1).Name = BookName End Sub
---
Ben Van Johnson
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks