using a fantastic tutorial by Debra Dalgleish i have this running sort of ..
but i need to have another column do the same action on a different workbook and it has me stumped. Any help would be appreciated.
Many thanks. and im sure it obvious .. but been decades for me
Option Explicit
Private Sub Worksheet_Change _
(ByVal Target As Range)
On Error GoTo errHandler
Dim wsCodes As Worksheet
Set wsCodes = Worksheets("Codes")
If Target.Cells.Count > 1 _
Then GoTo exitHandler
If Target.Column = 4 Then
If Target.Value = "" _
Then GoTo exitHandler
Application.EnableEvents = False
Target.Value = wsCodes.Range("A1") _
.Offset(Application. _
WorksheetFunction _
.Match(Target.Value, _
wsCodes.Range("ProdList"), 0), 0)
End If
exitHandler:
Application.EnableEvents = True
Exit Sub
errHandler:
If Err.Number = 13 _
Or Err.Number = 1004 Then
GoTo exitHandler
Else
Resume Next
End If
End Sub
Private Sub Worksheet_Change2 _
(ByVal Target As Range)
On Error GoTo errHandler
Dim wsCodes As Worksheet
Set wsCodes = Worksheets("Suppliers")
If Target.Cells.Count > 1 _
Then GoTo exitHandler
If Target.Column = 10 Then
If Target.Value = "" _
Then GoTo exitHandler
Application.EnableEvents = False
Target.Value = wsCodes.Range("A1") _
.Offset(Application. _
WorksheetFunction _
.Match(Target.Value, _
wsCodes.Range("SUPPDESC"), 0), 0)
End If
exitHandler:
Application.EnableEvents = True
Exit Sub
errHandler:
If Err.Number = 13 _
Or Err.Number = 1004 Then
GoTo exitHandler
Else
Resume Next
End If
End Sub
but i need to have another column do the same action on a different workbook and it has me stumped. Any help would be appreciated.
Many thanks. and im sure it obvious .. but been decades for me
Option Explicit
Private Sub Worksheet_Change _
(ByVal Target As Range)
On Error GoTo errHandler
Dim wsCodes As Worksheet
Set wsCodes = Worksheets("Codes")
If Target.Cells.Count > 1 _
Then GoTo exitHandler
If Target.Column = 4 Then
If Target.Value = "" _
Then GoTo exitHandler
Application.EnableEvents = False
Target.Value = wsCodes.Range("A1") _
.Offset(Application. _
WorksheetFunction _
.Match(Target.Value, _
wsCodes.Range("ProdList"), 0), 0)
End If
exitHandler:
Application.EnableEvents = True
Exit Sub
errHandler:
If Err.Number = 13 _
Or Err.Number = 1004 Then
GoTo exitHandler
Else
Resume Next
End If
End Sub
Private Sub Worksheet_Change2 _
(ByVal Target As Range)
On Error GoTo errHandler
Dim wsCodes As Worksheet
Set wsCodes = Worksheets("Suppliers")
If Target.Cells.Count > 1 _
Then GoTo exitHandler
If Target.Column = 10 Then
If Target.Value = "" _
Then GoTo exitHandler
Application.EnableEvents = False
Target.Value = wsCodes.Range("A1") _
.Offset(Application. _
WorksheetFunction _
.Match(Target.Value, _
wsCodes.Range("SUPPDESC"), 0), 0)
End If
exitHandler:
Application.EnableEvents = True
Exit Sub
errHandler:
If Err.Number = 13 _
Or Err.Number = 1004 Then
GoTo exitHandler
Else
Resume Next
End If
End Sub