Results 1 to 2 of 2

VBA code to delete VBA code

Threaded View

jet2004uk VBA code to delete VBA code 10-26-2012, 01:43 AM
JOHN H. DAVIS Re: VBA code to delete VBA... 10-26-2012, 09:58 AM
  1. #1
    Registered User
    Join Date
    10-05-2012
    Location
    Gainsborough, England
    MS-Off Ver
    Office 2016 & Office 365
    Posts
    87

    VBA code to delete VBA code

    Hi

    Very new to VBA, have been using a bit of code which saves a copy of a workbook to a different location and also clears cell contents in the original workbook this works great, what I have been trying to do is to add a bit more code to have the VBA deleted in the copy NOT the original workbook if that makes sense?? Did try saving the copy as a xlsx format as I thought that would strip the code but then when I try and open the copy I get an error and cant open it....something about file extention not matching...sorry for my noobness not sure how to proceed please see code below.
    Many thanks for any advice

    Private Sub CommandButton3_Click()
    Dim nom As String
    Dim newFile As String, fName As String
    Dim wb As Workbook
    Set wb = ActiveWorkbook
    fName = Range("D4").Value
    newFile = fName & " " & Format$(Date, "mmmm-dd-yyyy")
    ActiveWorkbook.SaveCopyAs Filename:="G:\Production - Shared\Saved Machine Logs\" & newFile & ".xlsm"
    Sheet1.Range("A8:D100,D4,F8:G100,J8:N100,Q8:S100,W8:X100").ClearContents
    ActiveWorkbook.Save
    Application.Quit
    End Sub
    Last edited by jeffreybrown; 10-26-2012 at 10:00 AM. Reason: Please use code tags...Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1