Hi Guys,
How to break this huge procedure into multiple small ones? The codes are much much bigger. I am copying and pasting partial codes here. Basically it is a user form that display the data from a table and the program takes some user input data from the form and populate them back into the table. The form has about 600 data fields and almost half of them are user input fields.
How to break this huge procedure into multiple small ones? The codes are much much bigger. I am copying and pasting partial codes here. Basically it is a user form that display the data from a table and the program takes some user input data from the form and populate them back into the table. The form has about 600 data fields and almost half of them are user input fields.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address = "$L$2" Then
V = Application.Match(Target.Value, Range("A151", [A151].End(xlDown)), 0)
If IsNumeric(V) Then
V = 150 + V
[F2].Value = Target.Value
[B2].Value = Cells(V, 2).Value
[D2].Value = Cells(V, 3).Value
[B4].Value = Cells(V, 4).Value
[C4].Value = Cells(V, 5).Value
[D4].Value = Cells(V, 6).Value
[E4].Value = Cells(V, 7).Value
[F4].Value = Cells(V, 8).Value
[G4].Value = Cells(V, 9).Value
[H4].Value = Cells(V, 10).Value
[I4].Value = Cells(V, 11).Value
[J4].Value = Cells(V, 12).Value
[K4].Value = Cells(V, 13).Value
[L4].Value = Cells(V, 14).Value
[B5].Value = Cells(V, 15).Value
[E5].Value = Cells(V, 16).Value
[G5].Value = Cells(V, 17).Value
Else
If Target.Value > "" Then Beep
[F2,B2,D2,B4,C4,D4,E4,F4,G4,H4,I4,J4,K4,L4].Value = ""
End If
'B2-Protocol Number
ElseIf Target.Address = "$B$2" Then
Dim prot As Integer
prot = Application.Match([F2].Value, Range("A151", [A151].End(xlDown)), 0) + 150
Range("B" & prot).Value = Range("B2").Value
[B2].Value = Range("B" & prot).Value
'D2-Theme Number
ElseIf Target.Address = "$D$2" Then
Dim theme As Integer
theme = Application.Match([F2].Value, Range("A151", [A151].End(xlDown)), 0) + 150
Range("C" & theme).Value = Range("D2").Value
[D2].Value = Range("C" & theme).Value
End If
Application.EnableEvents = True
End Sub