How To Delete Another Excel Private Module Of Workbook Object
Jul 9, 2013
How to delete another excel private module of the Workbook Object (ThisWorkbook) VBA codes of the workshook event.
This code to run from my PERSONAL.XLSB
Sub Macro1()
Windows("Book1.xls").Activate
ActiveWorkbook.Vbproject
Don't know what other codes I need to put after this
End Sub
This code to be deleted via Macro1 above code
Private Sub Workbook_Open()
Call CreateMenu
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call DeleteMenu
End Sub
View 2 Replies
ADVERTISEMENT
May 15, 2008
I want to write some code that runs everytime the workbook is initialized. I found out that the code should be placed in the following "Private Sub":
Private Sub Workbook_Open()
'My code
End Sub
I know that this code should be placed in the Private Module of the Workbook! I just can not find where is the Private Module of the Workbook in Excel 2007... =/
View 3 Replies
View Related
Aug 13, 2009
Is it possible to call a Private Sub from another Module?
View 2 Replies
View Related
Nov 25, 2008
I have some code in which I need to pass the value of "j" from one module to another. "j" is declared in Sheet1 (Data) under the Microsoft Excel Objects.
View 8 Replies
View Related
Aug 12, 2009
I am trying to pass a variable called "Filter" from a Private Sub to a Module but keeping coming up with a zero value in the Module. I tried to make the variable Global but that didn't seem to work.
Private Sub Code as follows:
View 3 Replies
View Related
Dec 15, 2006
I would like the users to be able to exit the whole module via double clicking the form. When the form is double clicked, the double click event appears and I am wondering how to put code into this procedure which exits the whole module.
View 3 Replies
View Related
Oct 17, 2003
When in a ThisWorkbook macro, I want to call a sub/macro in a Module. Usually you can just do a CALL MACRO1, and it will find it. But my MACRO1 is Private as I don't the users to be able to do a Tools, Macro, Macros and see it. So I don't want to make it a Public macro. So how do I call the private sub/macro from within ThisWorkbook?
Can I proceed the sub/macro's name with the name of the module, kind of like CALL MODULE1.MACRO1? Or do I have to make it public?
View 9 Replies
View Related
Nov 10, 2006
I've got a problem referring to a named range in another worksheet.
Private Sub test()
Dim var_StartWeek As String ' 0740 This is the value I make a lookup for
Dim var StartWeekNr As Integer ' 40 and get this as a result
'*** Here is the named range in another worksheet (It doesn't work)
Set rng = ActiveWorkbook.Names("WeekData2").RefersToRange
var_StartWeekNr = WorksheetFunction.HLookup(var_StartWeek, Range("rng.Value"), 4) ' I'm doing something wrong here...
'*** If I have the named range in the same worksheeet it works fine
'var_StartWeekNr = WorksheetFunction.HLookup(var_StartWeek, ActiveSheet.Range("WeekData"), 4)
View 3 Replies
View Related
Mar 26, 2008
I have a sheet that has a macro on it, I would like to run that macro programaticaly but Im not able to call it using Call mymacro type of code. The code that calls the macro resides in a module and the macro is in a sheet. Obviously they are not talking, is there a way to run it remotely without moving the macro into the module?
View 9 Replies
View Related
Mar 28, 2008
I am trying to pass a string array into a form. I have added a member string array to the form, and a property to "Let" the array in the the member array.
Private sFormString() As String
Property Let FormString(value() As String)
sFormString = value
End Property
I can pass a string in using a procedure:
Sub StringArrayTest1()
Dim TestString() As String
Dim frmString As FString
but I cannot "modulate" the code, or else I get an internal error (error 51). I.e. this code doesn't work:
Sub StringArrayTest2Mod(TestString() As String, frmString As FString)
frmString.FormString = TestString
End Sub
Sub StringArrayTest2()
Dim TestString() As String
Dim frmString As FString
Set frmString = New FString
Redim TestString(1 To 2)
TestString(1) = "Cat"
TestString(2) = "Dog"
Call StringArrayTest2Mod(TestString, frmString)
End Sub
Does anyone know why this happens? Obviously, in the example code its not an issue, but the application I'm using this for is more complex, and some modulation here would be good.
View 9 Replies
View Related
Sep 12, 2006
I'm having trouble calling a defined range within a VLOOKUP function in VBA. If the named range is located on the same sheet within which you are running the macro, everything runs fine and all is well in the world.
However, after I relocated the range to a separate sheet (a 'SourceData' sheet to tidy up the user interface sheet), I was getting the following error message:
Method 'Range' of object '_Worksheet' failed
The name is correctly defined - Range("DaysInYear").Select still picks up the correct selection - it's just the VLOOKUP will no longer function correctly.
Here is part of the macro's
For I = 1 To NumberOfDays
Range("A1").Value = DateAdd("d", -(I - 1), EndDate)
If Application.VLookup(Range("A1"), Range("DaysInYear"), 3, False) = 1 Then
If Application.VLookup(Range("A1"), Range("DaysInYear"), 4, False) = 0 Then
ActualNumber = ActualNumber + 1
End If
End If
Next I
View 9 Replies
View Related
Feb 13, 2013
I am using Excel 2010 and late binding to generate reports. The sheets are blank and unused. I have the UserForm being opened on Workbook_Open and the actual VBA for doing the work in a separate macro in the workbook. All the posts I have found are dealing with accessing cells from the UserForm and I haven't found any dealing with connecting a macro to the UserForm output.
My question is this: I want to return from the UserForm the flags of which reports to run to the (unopened) macro containing the code to do so. How do I open the macro and pass the variables to it?
The UserForm is creatively called "SelectionForm" and the macro is called "DailyFTP" with a Main sub as the entry. I know I can use the code under to capture the radio button and checkbox choices. I have other variables like the names of files set as global variables in the DailyFTP macro. The macro doesn't exist until SelectionForm opens it, so they must be set after the macro is in memory.
View 6 Replies
View Related
Oct 3, 2011
I have written a sub with the purpose of finding rows based on a critieria, copying the rows to another worksheet and deleting the original row.
The code:
Code:
Sub MoveToIgangvaerende()
'
' Flytter opgaven til sheetet Igangværende projekter
'
Dim i, j, Index As Integer
Forfra:
For i = -1 To 1000
If Sheets("Pipeline").Cells(3 + i, 20) = "Ja" Or Sheets("Pipeline").Cells(3 + i, 20) = "ja" Then
[Code] ......
I get the error message "Method 'Delete' of object 'Range' failed" at the line "Sheets("Pipeline").Cells(3 + i, 18).EntireRow.Delete".
The sub has previously worked perfectly fine.
View 4 Replies
View Related
Mar 20, 2014
I have a worksheet with a bunch of formulas in it. Computations are done on the worksheet and then I start a macro that copies the sheet and replaces the calculations with values.
The worksheet has a sheet level private sub.
View 6 Replies
View Related
Oct 5, 2007
In a workbook made in Excel 2003, I have the following for a UserForm:
Private Sub UserForm_Activate
Me.Calendar1.Value = Date
End Sub
I copied this workbook to a computer with Excel 2007 and it bombs out at "Date"
It comes up with a compile error, "Can't find project or library"
In the references window (Tools, References) it has the "Missing: Ref Edit Control" checked and the location at the bottom of this window states "C:Program FilesMicrosoft OfficeOffice11REFEDIT.DLL".
The reference to Office11 is from the computer with Office 2003 as the computer with Office 2007 has Office12.
There is another "Ref Edit Control" in the References window and when I check it and browse to the Office12 folder, highlight REFEDIT.Dll and click on open and in the references window on OK it comes up with "Name conflicts with existing module, project or object library". I have tried to delete the "Missing: Ref Edit Control", change the priority and change the reference in the missing control to Office12 but all to no avail.
How can I change the reference to the Ref Edit Control from Office11 to Office12?
View 3 Replies
View Related
Oct 11, 2013
I want this private sub macro to change work in all workbook. How it possible?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
With Target.EntireRow.Interior
.ColorIndex = 37
.Pattern = xlGray25
.PatternColorIndex = 24
End With
End Sub
View 4 Replies
View Related
May 19, 2014
I have pulled a SharePoint list into my workbook. The list object (table) is still linked to the SharePoint list, as I'd like to synchronize it later on. I have filtered it with an autofilter. I'd like to delete all of the visible rows. I have tried a billion things to no avail. I have been searching Google for hours now. None of the examples work.
View 5 Replies
View Related
May 25, 2009
I inserted a second module into a project. Now I want to delete it. Only i can't figure out how to do this. I highlite it and right click or click edit from the toolbar but i'm provided no options. I can't drag it to the trash either.
View 2 Replies
View Related
Jun 23, 2014
I am looking for a code to create a new vba module. then cope all the code from 1 vba module(without empty line) to the newly created module. then delete the old vba module. does such a code exist?
View 1 Replies
View Related
Nov 24, 2006
I have a problem deleting Module1 then saving the worksheet and keeping the module1 deleted. Without the rem'd code (shown below) a popup asks if you wish to save the changes; if you say "No" the module reappears in the file, and "Yes" the module stays deleted. Even with any of the Rem'd out code below the workbook is saved and closed, but on reopening the code module is still there. My problem is I don't want the user to have the choice, the workbook must be saved without the module. As this is a price quote program, with the module still in the Project, reopening and closing the saved workbook causes an error as the macro cannot find the deleted worksheets to delete!
This is a very small test program for a much bigger one that has quite a bit of security in it.
Sub deletetest()
Dim x As Object
Application.DisplayAlerts = False
Sheets("Sheet2").Delete
Sheets("Sheet3").Delete
e = Sheets("Sheet1"). Range("B4") ' account name
f = Format(Sheets("Sheet1").Range("B3"), "ddmmyy") ' date quote saved, cell = NOW()
thisfile = e & "-" & "-" & f 'changed to name, Acc No, dat
View 7 Replies
View Related
Apr 25, 2006
I have this piece of code which copies module1 from file1 to all other open files which I list below open.
I want to modify it so that it will delete module11 as it goes.
Dim FName As String
Dim FName1 As String
With Workbooks("CFADS01") 'copies from here
FName = .Path & "code.txt"
.VBProject.VBComponents("Module1").Export FName
End With
'copies into these workbooks
'all workbooks need to be open
Workbooks("CFADS01").VBProject.VBComponents. Import FName
Workbooks("CFADS02").VBProject.VBComponents.Import FName
View 9 Replies
View Related
Dec 13, 2006
how to write a procedure to delete macro code that is in the worksheet property? I created a and excel model for a colleague which had many macro procedures including "Worksheet_Activate". The problem is now this individual moves the worksheets into new workbooks and this is cause many runtime errors. Is there a way I can write a copy/move procedure that also deletes the Worksheet Activate macro so that error does not appear?
View 2 Replies
View Related
Feb 27, 2007
I have macro in ThisWorkBook that runs when I open the workbook
Private Sub Workbook_Open()
I would like to to delete this macro using a script that I have in a Module. There is another macro in ThisWorkBook which I want to keep.
View 3 Replies
View Related
Apr 16, 2009
I want to delete the contents of every cell without deleting any code from my module. The reason I ask is, I'm reading from a text file into excel.
I want to run my code to read text into excel one time through. Then i want to delete all the text, make some alterations to my code, and run the code again. That way each time the worksheet is fresh and clear before i run the code.
View 4 Replies
View Related
Mar 20, 2007
I will shortly be running a project over a twenty four hour period, where a group of people will be inputting data into a workbook (one worksheet per hour), and what I would like to know is if it is possible, to input some coding into a thisWorkbook module to action a save on the workbook every time an entry is placed in column A (of each worksheet) which is divisable by 10 (a10, a20, a30 etc).
View 2 Replies
View Related
Oct 29, 2013
I have a file that has an original file format .xls
I saved as .xlsx (I am using Excel 2007) with a different name so I could make changes to the new file without changing the original.
That turn off compatibility mode.... but it is still "shared". While it is shared I cannot delete a sheet. In fact, I really don't even want it to be shared. If the file is open, and someone else opens it, I want it to open as "read only". I cannot uncheck the "Allow changes by more than one user at the same time. This also allows workbook merging." checkbox because it is greyed out.
View 3 Replies
View Related
Oct 20, 2008
The following code deletes a specific connection in a workbook:-
ActiveWorkbook.Connections("text123").Delete
How can I code this so that I can delete ALL connections in a workbook without having to specify the names (as these will always be different).
View 3 Replies
View Related
Jul 14, 2006
Is there anyway to copy a module from one workbook to another using a macro?
View 6 Replies
View Related
Jun 21, 2013
Want to Copy a Module(s) to another workbook in a different path and also password protect it at the same time using VBA.
I need to copy some Module(s) from One WorkBook to another using VBA..
I have used the following code to good effect, however my TargetWb is not at the same path, so I need some modification in this code if that's possible and also this VBA Module which is Copied and Pasted in the Target WOrkbook needs to be Password Protected so that it cannot be tampered.
The code which I'm using currently is:
Code:
Sub CopyModule(SourceWB As Workbook, strModuleName As String, _
TargetWB As Workbook)
' copies a module from one workbook to another
' example:
' CopyModule Workbooks("Book1.xls"), "Module1", _
[Code]...
Code:
Sub Try()
Call CopyModule(Activeworkbook, "Module1", TargetWb)
on this to pass the TargetWb as a variable which can be generated in the code used for generating the File using a Macro..
End Sub
In the above code The SourceWB would be the ActiveWorkbook and the Target Workbook is the file created using another Macro from several sheets of the Active Workbook and its created in a folder with a specific name and therefore the Path is one more level inside than the Active Workbook.
if the Transferred Module can be Passworrd Protected and Locked for editing..for the end user.
View 9 Replies
View Related
Jan 18, 2014
I am creating a File/Workbook using MACRO, however i need to ensure that one of the Modules in the created workbook remains protected and hidden...
Since there are lot of these files which are created, I would be interested in protecting them via a macro..
View 4 Replies
View Related