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.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
loryci_2006 pe Simpatie
Femeie
21 ani
Bucuresti
cauta Barbat
21 - 49 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [EXCEL] Step 2 - Insert VBA Code into Active Sheet Code [VBA] Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 748
If you want to dynamically (using a button) insert the VBA code required for this:

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


Modificat de TRaP (acum 5 ani)


pus acum 5 ani
   
Pagini: 1  

Mergi la