+ Reply to Thread
Results 1 to 6 of 6

code that will delete and clear specific contents in the workbook

  1. #1
    Forum Contributor
    Join Date
    10-10-2012
    Location
    Mumbai,India
    MS-Off Ver
    Microsoft Excel 2007
    Posts
    104

    code that will delete and clear specific contents in the workbook

    Hi everyone,
    I don't know whether it is possible in excel or not.
    I have an invoice template which contains macros formula and a data validation list source in it . Now I need a macro that would remove these data from the workbook if the workbook is saved by different name or any other way to automate this task of clearing the above mentioned content using macro
    For example:
    My Invoice template is named United Printer.xlsb ( it will contain all the data ie "macros formula and a data validation list source in it")
    Now when I save this template with a different file name let for example 1254.xlsb it should run the macro and clear the above mentioned data
    This post has been edited from here
    http://www.thecodecage.com/forumz/mi...-workbook.html

    Replies awaited .
    Thanks
    MZ

  2. #2
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: code that will delete and clear specific contents in the workbook

    To Clear out contents from cells, we basically use ClearContents() available within Range() or Cells(). You simply have to select those ranges first, say if they are from A1 to A100, then code would be
    Please Login or Register  to view this content.
    To delete the validations, we use Validation.Delete() available within Range() and Cells(). So if we have validation in cells A2 to A3, then
    Please Login or Register  to view this content.
    cOdEsLiZeR - Back after a long break.. Let's sLiZe some more cOdEs!!

  3. #3
    Forum Contributor
    Join Date
    10-10-2012
    Location
    Mumbai,India
    MS-Off Ver
    Microsoft Excel 2007
    Posts
    104

    Re: code that will delete and clear specific contents in the workbook

    Hi Codeslizer !
    Thanks for your reply and would you tell me have to remove all the macros from the saved workbook ??
    And also could you merge those two codes in single ?

  4. #4
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: code that will delete and clear specific contents in the workbook

    In order to remove all of the macros from the sheet, you'll have to do it manually. Open VBA editor using Alt + F11. On the left side of your screen, you'll find Projects list, if not, press CTRL+R.

    1. Remove any modules, if available
    2. Remove any class modules, if available
    3. Double click and open each sheet, and press CTRL+A and then DELETE.

    That should do for removing all macros. Please note, you'll have to know the VBA password if security is applied to the file.

    Regarding your merging request, it depends. Not all of the codes can be merged together just like that. It depends on the scope of the codes. If a code is programmed to work within the scope of a sheet, then it'll work only in the sheet and not outside it. You'll have to redefine scope for if you wish to consolidate it into one.

  5. #5
    Forum Contributor
    Join Date
    10-10-2012
    Location
    Mumbai,India
    MS-Off Ver
    Microsoft Excel 2007
    Posts
    104

    Re: code that will delete and clear specific contents in the workbook

    Is it not possible to record your above said procedure to remove all macros from a file and save the thus obtained macro in Personal.xlsb to make it available to all open workbook

  6. #6
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: code that will delete and clear specific contents in the workbook

    Well, you never said you wanted a macro to all macros from the sheets.. :p

    check out Ivan's post on this link : http://www.mrexcel.com/forum/excel-q...lications.html

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Modify Macro : Clear contents <> Delete
    By guatelize in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-25-2013, 06:09 AM
  2. Code to clear contents of specific cells based upon if key exists in other sheets
    By seputus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2013, 07:25 PM
  3. Delete rows or Clear contents below a specific word is found in Column A
    By kishoremcp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-17-2012, 04:08 PM
  4. [SOLVED] Conditionally Clear Contents for Specific Range
    By rlpowers in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-08-2012, 01:56 PM
  5. [SOLVED] Macro to clear & delete contents on other worksheets
    By matrixpom in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-04-2012, 06:15 PM

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