PDA

View Full Version : Export to Excel clt: Disable worksheet event



clueless007
06-29-2008, 10:04 PM
Hello
I have an excel.xlt file that has a worksheet event procedure
Public sCellAdd As String
Public iPic As Integer
Public sCell As String
Public iRow As Integer
Dim windowWidth As Double, widthOffset As Double
Dim windowHeight As Double, heightOffset As Double

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Application.ScreenUpdating = False
If InRange(Target, Range("Board")) Then
On Error Resume Next
ActiveSheet.Range("G" & sCell).Select
Sheets("ClientDetails").Shapes("Pic1").Copy
Sheets("Sheet1").PasteSpecial Format:="Picture (GIF)", Link:=False, _
DisplayAsIcon:=False

With ActiveWindow
If 1 < .VisibleRange.Column Then
widthOffset = Range(ActiveSheet.Cells(1, 1), ActiveSheet.Cells(1, .VisibleRange.Column - 1)).Width
End If
If 1 < .VisibleRange.Row Then
heightOffset = Range(ActiveSheet.Cells(1, 1), ActiveSheet.Cells(.VisibleRange.Row + 1, 1)).Height
End If

windowWidth = .UsableWidth
windowHeight = .UsableHeight

End With

ActiveSheet.Shapes.Select
With Selection
.Top = ((windowHeight - .Height) / 2) + heightOffset
.Left = ((windowWidth - .Width) / 2) + widthOffset
End With
' ActiveSheet.Buttons.Add(467, ((windowHeight - Height) / 2) + heightOffset, 35.25, 16.5).Select
ActiveSheet.Buttons.Add(537, ((windowHeight - Height - 325) / 2) + heightOffset, 35.25, 16.5).Select
Selection.OnAction = "DeleteShapes"
ActiveSheet.Shapes("Button 5").Characters.Text = "Close"
Selection.Characters.Text = "Close"
Cells(sCell, 3).Select

End If
Application.ScreenUpdating = True
End Sub

Private Function InRange(rng1, rng2) As Boolean
' Returns True if rng1 is a subset of rng2 InRange = False
If rng1.Parent.Parent.Name = rng2.Parent.Parent.Name Then
If rng1.Parent.Name = rng2.Parent.Name Then
If Union(rng1, rng2).Address = rng2.Address Then
InRange = True
' iRow = (Cells(rng1, rng2))
' iRow = rng1 + 3
iCellAdd = rng1.Value
Sheets("ClientDetails").Range("B2") = iCellAdd
sCell = rng1.Row
End If
End If
End If
End Function

The problem is that I want to disable this/comment it out, because I do not want it run yet, only when I'm finished.. can anyone help, thanking you

CreganTur
06-30-2008, 06:34 AM
The problem is that I want to disable this/comment it out, because I do not want it run yet

You've answered your own question- just select all of the text and then click on the Comment Block button on the Edit Toolbar- this will comment out everything you selected.:thumb