Worksheet change code to work from VB
I am using the following code in excel to perform a job:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 And Target.Row = 2 Then
' do this
End Sub
How can I use this type of codes ie not related to Excel VBA module from
VB6?
Re: Worksheet change code to work from VB
why would you change it? it will still work if the workbook is opened from vb6
Re: Worksheet change code to work from VB
Thanks for the reply.
I want to put the code in VB6 and not in the excel file The full code is like this
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 And Target.Row = 2 Then
Sheets("Statement").Rows.Hidden = False ' This is new line to unhide earlier rows
For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
If (Cells(i, 3) = 0 And IsEmpty(Cells(i, 3)) = False) Or _
(Cells(i, 4) = 0 And IsEmpty(Cells(i, 4)) = False) Or _
(Cells(i, 5) = 0 And IsEmpty(Cells(i, 5)) = False) Then
Cells(i, 1).EntireRow.Hidden = True
End If
Next
End If
End Sub
I want to trigger this code from VB6 and doesnot want to keep in the excel file.