Gowri A

Gowri A

  • NA
  • 54
  • 47k

how to add excel sheetchange event to c#

Sep 9 2014 10:12 AM
How to add the following excel vba sheetchange event to c#



Private Sub Worksheet_Change(ByVal 

Target As Range)
If Not Intersect(Target, Range("A1", 

"A101")) Is Nothing Then
        Dim CellAddress, address, 

position, formula1 As String
        CellAddress = Target.address
            If Range(CellAddress).Value 

<> "" Then
            address = CellAddress
            position = Mid(address, 4, 

3)
                Range("B" & 

position).Select
                Range("B" & 

position).Clear
                With 

Selection.Validation
                    .Delete
                     .Add 

Type:=xlValidateList, 

AlertStyle:=xlValidAlertStop, 

Operator:= _
        xlBetween, 

formula1:="=indirect(A" & position & 

")"
                    .IgnoreBlank = True
                    .InCellDropdown = 

True
                    .InputTitle = ""
                    .ErrorTitle = ""
                    .InputMessage = ""
                    .ErrorMessage = ""
                    .ShowInput = True
                    .ShowError = True
                End With
            End If
    End If
End Sub