Hi,
I,m trying to combine the following two code as one code. Any help on this would be kindly appreciated.
I,m trying to combine the following two code as one code. Any help on this would be kindly appreciated.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Dim r As Long
Dim m As Long
Dim n As Long
Dim wsh As Worksheet
Dim lngSerial As Long
If Not Intersect(Range("O6"), Target) Is Nothing Then
Application.EnableEvents = False
Range("F18:F37").ClearContents
Range("N18:N37").ClearContents
lngSerial = Range("O6")
n = 17
Set wsh = Worksheets("OrderData")
m = wsh.Range("F" & wsh.Rows.Count).End(xlUp).Row
For r = 5 To m
If wsh.Range("B" & r) = lngSerial Then
n = n + 1
Range("F" & n) = wsh.Range("C" & r)
Range("N" & n) = wsh.Range("G" & r)
End If
Next r
Application.EnableEvents = True
End If
Application.ScreenUpdating = True
End Sub
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim wshI As Worksheet
Dim rng As Range
If Not Intersect(Range("O6"), Target) Is Nothing Then
Set wshI = Worksheets("Invoice")
Set rng = wshI.Range("B:B").Find(What:=Range("O6").Value, LookAt:=xlWhole)
If rng Is Nothing Or Range("O6") = "" Then
Range("I9:I10,M9:M10,M15,O9:O11").ClearContents
Else
Range("I9") = rng.Offset(0, 13)
Range("I10") = rng.Offset(0, 1)
Range("M9") = rng.Offset(0, 11)
Range("M10") = rng.Offset(0, 2)
Range("M15") = rng.Offset(0, 5)
Range("O9") = rng.Offset(0, 12)
Range("O10") = rng.Offset(0, 10)
End If
End If
End Sub