Hi all, im self teaching myself vba and I have a problem trying to combine my 2 vba codes.
Code 1 -This bit of code uses (H:H) as a drop down list, which then pastes a vlookup to the next cell to lookup data on a separate data worksheet (Supplier Details) It then copies the cell an pastes its as values instead of having a formula in the cell.
Code 2 - The cell in column 26 is a drop down closed or open. This determines if it is closed, then the date is added to the next cell.
Thanks
Code 1 -This bit of code uses (H:H) as a drop down list, which then pastes a vlookup to the next cell to lookup data on a separate data worksheet (Supplier Details) It then copies the cell an pastes its as values instead of having a formula in the cell.
Code:
'supplier details
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("H:H")) Is Nothing Then Exit Sub
Application.ScreenUpdating = False
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[0]C[-1],'Supplier Details'!R[-4]C[-8]:R[322]C[-7],2,FALSE)"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
Code 2 - The cell in column 26 is a drop down closed or open. This determines if it is closed, then the date is added to the next cell.
Code:
'Add Closed Date
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Target.Column = 26 And Target.Cells.Count = 1 Then
'Determine if Termed was chosen
If Target.Value = "Closed" Then
ActiveSheet.Unprotect 'Password:="password"
Range("AA" & Target.Row) = Date
Application.EnableEvents = False
ActiveSheet.Protect 'Password:="password"
Application.EnableEvents = True
End If
End If
End Sub
Thanks
Last edited by a moderator: