Filehost.ro - gazduire fisiere
Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Nou pe simpatie:
swiss_virginia Profile
Femeie
25 ani
Cluj
cauta Barbat
27 - 54 ani
Mrrrr's Forum (VIEW ONLY)ReguliInregistrareLoginPozeNu sunteti logat. Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides /

[EXCEL] Step 2 - Insert VBA Code into Active Sheet Code [VBA]

Pagini: 1 Moderat de TRaP, TonyTzu
#1
TRaP
Moderator
Postari: 963
If you want to dynamically (using a button) insert the VBA code required for this:
http://mrrrr.3xforum.ro/post/1691/1/EXC ... cted_VBA_/

You need the following code in your personal.xlsb:

' You need to go to TOOLS - REFERENCES and add the following library:
' Microsoft Visual Basic for Applications Extensibility 5.3

Sub Z_2AddCodeToSht()
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim xPro As VBIDE.VBProject
    Dim xCom As VBIDE.VBComponent
    Dim xMod As VBIDE.CodeModule
    Dim xLine As Long

    Set wb = ActiveWorkbook
    Set ws = ActiveSheet

    With wb
        Set xPro = .VBProject
        Set xCom = xPro.VBComponents(ws.CodeName) '.CodeName for VB sheet name; .Name for Excel tab names
        Set xMod = xCom.CodeModule

        With xMod
            xLine = .CreateEventProc("SelectionChange", "Worksheet")
            xLine = xLine + 1
            .InsertLines xLine, "  Target.Calculate"
        End With
    End With

End Sub


The following snippet will be inserted:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  Target.Calculate

End Sub


 
   

Topicuri similare

Pagini: 1  
Mergi la