Remove Macros With Code
Jun 24, 2007
I have developed a series of spreadhseets in which I use a macro to derive and insert the data from a SQL Server db. These spreadsheets may have one or more worksheets, some of which start as blank "canvases", others are preformatted with static data.
They are used for client reporting so are heavily formatted and include graphs; some manual preformatting, some coded, some graphs drawn completely by the code, some already in place - I just populate the data source. The VBA for the most complex one extends to around 5-6000 lines of code.
While this code does not add a huge amount to the footprint of the files, I feel that it is inappropriate for the spreadsheets to be distributed to the end clients with all this code included. The code is password "protected" but we all know how effective that can be although that is not really the point anyway - I simply feel it would be more professional if the code were not there at all.
There doesn't seem to be any options on a "Save As" method which enable the resulting sheets to be saved without the macros. I have tried recording a macro in which all I did was to delete the macros concerned - nothing was recorded. So a macro to remove macros seems to be out of the question.
These spreadsheets are held in a master folder on a server and are set as "read only". The users start the a sheet, run the macro (via a menu item which displays a selection form) and then save the resulting spreadsheet as another file in another location. I am wondering if there is some way I can cut into this process and develop my own "save" routine.
View 4 Replies
ADVERTISEMENT
Aug 23, 2009
I have a website that I have been posting filtered worksheets of specific formats of items for interested viewers to view. The Looker can click on the Button and Open or Save a Copy of the Worksheet. I hide unused rows and columns to reduce size.
I filter my main worksheet to find the item type that I want to isolate - I copy the Result to another file - Run a Macro to Remove the information that I dont want to show. Hide Unused rows and Columns. Save as my File name and Upload to the Website.
BUT -- In my Excel Workbooks I have Macros - Some in the personal file. Some attached to Specific Files. When the Viewer clicks to see the file -- it offers the Macros ( Enable or Disable ). This Scares off many viewers and they Cancel.
When I delete the macros and save -- it deletes the Macros from MY computer as well.
How can I remove Macros from only the Sheet that I want to post for my website.
Here is the URL of one of the Current Buttons to a posted file if you care to view and see what I mean and am attempting to do.
View 9 Replies
View Related
Jun 17, 2009
I would like to email an Excel file without the macros so the end recipients will only see the data and not be confused or excited about the prompt to enable/disable macros.
View 2 Replies
View Related
Dec 17, 2006
I am trying to come up with some code to loop through all worksheets in the workbook and remve assigned macros from any buttons on each sheet
My code below. I type btn. and reviewed the items offered by intellisense, but nothing seemed fitting.
Sub RemoveAssignedMacro()
Dim wb As Workbook
Dim btn As Shape
Dim sht As Worksheet
Set wb = ThisWorkbook
For Each sht In wb.Worksheets
For Each btn In sht.Shapes
btn.
Next btn
Next sht
End Sub
View 8 Replies
View Related
Apr 18, 2007
I'm just finishing up a project involving migrating an old Excel 4 macro to VBA. Unfortunately, now that my spiffy (and slow) VBA is finished, I can't find a way to delete the Excel 4 macro! I've tried going to Tools -> Macro -> Macros, and while the old macros are shown there, the delete button is greyed out!
View 3 Replies
View Related
Jan 4, 2010
I'm trying to teach myself VBA code and macros, and I can't work out where the code should go. Do I double click on the worksheet, and put the macro code there, or do I have to create a 'module' and put the code there? I have tried to find online tutorials but I really need a 'for idiots' guide.
View 6 Replies
View Related
Oct 3, 2012
I need something that will exit all macros currently in place. The reason i am asking for this is because i have code that uses Application.Run to run another macro within the current code. If the other macro called on in Application.Run has a msgbox which has an OK/Cancel option, i want the Cancel button to exit all macros, not just the one that is used to access the message box via the Application.Run.
this is the portion fo the code that shows the cancel button and my attempt to use Exit Sub; however, this only exits the current sub, not all subs.
Code:
If TnC4 = vbCancel Then
msgbox "This application has been cancelled.", vbInformation, "CANCELLED APPLICATION"
Application.Run "CLEAR"
Exit Sub
End If
View 2 Replies
View Related
Jul 31, 2014
I have 3 different sets of macros and i want to Join them together so i only have to run 1 macro to do all 3. I am not sure how the best way is to do this.
Code 1:
Code:
Public Function UserName()
UserName = Environ$("UserName")
End Function
Private Sub RefreshTeamQueryOnWorksheet(worksheetName As String)
[code]....
View 2 Replies
View Related
Sep 10, 2006
In a workbook with several worksheets i would like (as part of a backup function) make a copy of one of the worksheets.
The code of the complete project is distributed over a module (module1) and several Microsoft excel objects ("thisWorkbook", but also in a number of the worksheets (e.g. in "sheet3 (Risk Management Plan)").
The backup copy of the worksheet (in this example also containing e.g. the Microsoft excel object "sheet6 (Backup of Risk Management Plan)" should be free of any macro code. this to avoid unintended problems by inexperienced users, but also to keep the file size limited.
Probably it would be possible to copy the worksheet without of copying also the code. Or it would be possible to strip the code only from this particular worksheet without influencing any other code, forms, ... . Or, perhaps, there would even a totally different approach.
I use Windows XP pro Sp2, and Excel 2000 Sp3.
View 7 Replies
View Related
Jul 6, 2012
I have two columns one with the variables names and the other with the values now I have to assign vales to teh variables dynamically using the macros and vba code.
View 7 Replies
View Related
Jun 27, 2007
I have used the following Macro that deletes the Macro code. It then saves the file and quits excel.
*************************************
Sub removeAllCode()
Dim awi
Dim awcl As Integer
Dim count As Integer
Dim i As Integer 'loop counter
On Error Resume Next
count = ActiveWorkbook.VBProject.VBComponents.count
For i = 1 To count
Set awi = ActiveWorkbook.VBProject.VBComponents.Item(i)
awcl = awi.CodeModule.CountOfLines
awi.CodeModule.DeleteLines 1, awcl
Next i
Set awi = Nothing
ThisWorkbook.Save
Application.Quit
End Sub
*************************************
However when I open the Excel File, I still get the Macro Prompt. I have checked in Macro list as well as in VB Editor and no Macro code exists
If I have the file manually (or do a save as) and then reopen the file, I no longer get the Macro prompt.
I have tried various examples listed in different forums/sites but nothing works.
View 9 Replies
View Related
Oct 23, 2006
I prtected several sheets with the xlVeryHidden command I got from you. But when the user does not allow Macros to be executed, also these protections are not executed. Does there exist any solution to this problem? Something like "when macros are not allowed do NOT open file"?
Sub workbook_open()
Application.DisplayAlerts = False
Application. ScreenUpdating = False
Application.AskToUpdateLinks = False
Windows("rechenfile.xls").Activate
Sheets("Daten").Visible = xlVeryHidden
Sheets("Koeffizient").Visible = xlVeryHidden
Sheets("Investitionen").Visible = xlVeryHidden
Sheets("Konsum").Visible = xlVeryHidden
Sheets("Zinssatz_permanent").Visible = xlVeryHidden
Sheets("Preise").Visible = xlVeryHidden
Sheets("Nettotransfers").Visible = xlVeryHidden
Sheets("Beschäftigung").Visible = xlVeryHidden
Sheets("Löhne").Visible = xlVeryHidden
Sheets("Nettoexporte").Visible = xlVeryHidden
End Sub
View 4 Replies
View Related
Jan 23, 2007
I am encountering an error(-2147417848) when running my existing code. I did a little research and found on MSKB Q319832 information that suggests that I might try qualifying my code (not that I know what that means : D) In the article, it suggests using something like the below:
Dim oXL As Excel.Application
Set oXL = New Excel.Application
oXL.Visible = True
.....
.....
oXL.Quit
Set oXL = Nothing
I tried this approach and it fails as soon as it hits the event portion of the macro:
If oXL.Target.Address = "$C$2" Then
....
End If
I need to understand how the oXL object is used against information in my existing workbook.
View 2 Replies
View Related
Mar 13, 2014
I have made several Shapes and assigned macros to them, all is good.
What i am curious about: is it possible to highlight or change colour of the shape on press and return to normal if another is shape is pressed? Just anything to make that particular shape stand out that it has been selected then return to normal when another shape has been selected...
[Code] ....
That is the code so far that is attached to 1x shape...
View 5 Replies
View Related
Dec 16, 2008
I need to copy my worskheet multiple times to create about 10 of the same worksheets within a workbook. I know if you click in the very most top left hand corner of the worksheet, then click copy, go to the new worksheet and click paste, it copies the whole page, but it does not copy over the VBA Code.
Also, for some reason, it does copy over my macro buttons, but does not put some of them in the right spot?
View 6 Replies
View Related
May 30, 2007
I've used the following code to export macros from one workbook to another but I was wondering how you export macros from the ' Sheet' code module to the 'Sheet' code module of another workbook.
Sub Import_Macro()
With ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule
strRet = .Lines(1, .CountOfLines)
End With
Set wkb = Workbooks("Test Workbook.xls")
wkb.VBProject.VBComponents. Import ("G:SCSSCSALLReportsVB MacrosGeneral.bas")
wkb.VBProject.VBComponents.Import ("G:SCSSCSALLReportsVB MacrosMJ Selections.bas")
With wkb.VBProject.VBComponents("ThisWorkbook").CodeModule
.DeleteLines 1, .CountOfLines '//Delete Codes already wrriten
.InsertLines 1, strRet '// Write Code
End With
End Sub
View 8 Replies
View Related
Dec 23, 2009
I'm verrry new to editing VBA code and I've been trying to figure out how to send a column of data ("Min Data" AB3:AB21 from "Sheet1") to a worksheet ("F4" - Min) and sending another column of data ("Max Data" AC3:AC21 from "Sheet1") to a different worksheet ("F4" - Max) by using only the one button ("Record Data" from "Sheet1"
I've been trying to figure out ways to edit the VBA in "Module 1" to make this work
Can anyone help me out here? If what i'm asking for isn't clear enough, just let me know and i'll try to explain in more detail.
View 6 Replies
View Related
May 16, 2014
See attached file illustrating exactly what I'm trying to do.
I won't repeat the exact same things I wrote in the file, but the Summary is that I need to first make such that only certain check boxes can checked at any one time, then make the command button run certain macro(s) depending on which boxes are checked.
View 8 Replies
View Related
Sep 10, 2008
I have a spreadsheet with two modules. In an effort to reduce the file size of an archive, I’d like to remove some of the code (i.e., Module1). I have a macro that attempts to do this.
There are three parts to the operation. The first removes Module1; the second Quits the application; the third saves the changes. If I run each of these operations separately, it works fine. However, I’d like to do this with only one macro (SKK4). For some reason, it does not remove the Module.
Here is my test
Sub skk1()
ThisWorkbook.VBProject.VBComponents.Remove_
ThisWorkbook.VBProject.VBComponents("Module1")
End Sub
Sub skk2()
Application.Quit
End Sub
Sub skk3()
ThisWorkbook.Close SaveChanges:=True
End Sub
Sub skk4()
skk1
skk2
skk3
End Sub
View 9 Replies
View Related
May 14, 2006
Private Sub Dupe_Remover()
'29/06/2005 by nhunter
Application. ScreenUpdating = False
Dim R1 As Range
Dim drow As Integer
Dim lastitem As String
Set R1 = ActiveCell
loopst:
If Trim(ActiveCell) = "" Then
Goto procend
End If............
View 9 Replies
View Related
Sep 18, 2006
I have a VBA sub "Create Invoice". After I run it, I would like to remove it, using a CleanUp sub.
Is it a good assumption that a VBA routine is simply an object like any other object?
If so, what is the VBA code to remove a sub?
Does it matter whether the sub is a free standing module, or a sub that is attached to a worksheet?
View 6 Replies
View Related
Sep 18, 2007
I am using the following code to select rows in a filter.
Selection.AutoFilter Field:=Worksheets(" Dashboard"). Range("G1"), Criteria1:=Worksheets("Dashboard").Range("H1")
This code runs when I click a command button on a userform.
When I load the userform up again I want to clear off the previous filter before I filter again as there are 4 columns which have filters on.
I have tried using ActiveSheet.ShowAllData before filtering again but this code falls over if there isn't a filter already on.
View 4 Replies
View Related
Jul 9, 2014
I have created a individual tracker spread sheet in each user system and on the spread sheet I have inserted 2 buttons in 1st sheet. when employee wants to take a break he has to click on the log out button and when he came back he needs to click on login button. I have another sheet named "timings" and I have created 2 columns, one is login and another is logout. What I need is when user click on the login button, the system time and date to be auto update under login column and when he clicks on logout button the system time and date to be auto update under logout column.
View 14 Replies
View Related
Apr 10, 2014
I have a set of text in rows which includes duplicates like this:
Column A
Text 1
Text2
Text1
Text500
Text500
I then need to remove the duplicates and put them in column B. I normally use the remove duplicates button in Excel to do this but seeing as I have to do this task every day, I was hoping there would be either a formula or VBA solution which automatically does this?
View 4 Replies
View Related
Mar 23, 2014
I have the need to remove an ellipsis from an active cell within a spreadsheet. These are inserted manually by agents in a call centre. However when this information is migrated onto another system, any ellipses cause the second system to crash. (I don't know the reason behind this).
I have been asked to look at the possibility of removing these using code. I currently have a macro running to remove any punctuation and do spell check on a command button for the active cell and was wondering what the code would be to add to this macro. I am using the replace command to find "." etc and replace with " ".
View 6 Replies
View Related
Sep 2, 2009
Is there code available that will hide the Tools Menu within excel?
View 5 Replies
View Related
Apr 12, 2012
I am trying to create code that I can use to to update a macro module automatically so I don;t have to keep having my users manually import when we have update to the module.
Here is the code I have so far.
Private Sub Workbook_Open()
Call UpdateTJMacros
'This is in the module we are replacing
Call MyOpenWorkbookMacro
[Code] ...........
View 3 Replies
View Related
Dec 15, 2012
share a code to remove BLANK ROWS.
I have data on ROW#1, #5, #10...etc,etc.. I want to remove rows in btwn (which is blank) Instead of doing manually
View 2 Replies
View Related
Jan 26, 2007
I have built a tool that automates the creation of some excel models. When each one of these models is created and deployed I need it to have all VBA code removed from it.
What vba command can I run that will strip all vba code out of a chosen workbook?
View 9 Replies
View Related
Aug 20, 2014
I have a list of addresses, which are comma separated, all ending with a PostCode
How Can i strip out the PostCode field?
View 3 Replies
View Related