Hi everyone hopefully this is my final question for today.
i have a worksheet called "Fees Paid" that uses data validation in column "B", the user selects a name from the list and all other cells auto populate with matching data.
Columns A, C, D, E, F, G and H, cells G & H are dates.
"Fees Paid" looks at Sheet "Members" to return matching data
My problem is that my code works fine, although once a name has been selected it takes along time to populate the other cells like a minute or so can this code be sped up please see code below..
Thankyou in advance..
i have a worksheet called "Fees Paid" that uses data validation in column "B", the user selects a name from the list and all other cells auto populate with matching data.
Columns A, C, D, E, F, G and H, cells G & H are dates.
"Fees Paid" looks at Sheet "Members" to return matching data
My problem is that my code works fine, although once a name has been selected it takes along time to populate the other cells like a minute or so can this code be sped up please see code below..
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Value = "" Then Exit Sub
Dim sh As Worksheet, f As Range
If Not Intersect(Target, Range("B:B")) Is Nothing Then
Set sh = Sheets("Members")
Set f = sh.Range("B:B").Find(Target.Value, , xlValues, xlWhole)
If Not f Is Nothing Then
'cell destination cell origin
Cells(Target.Row, "A").Value = sh.Cells(f.Row, "A").Value
Cells(Target.Row, "C").Value = sh.Cells(f.Row, "C").Value
Cells(Target.Row, "D").Value = sh.Cells(f.Row, "D").Value
Cells(Target.Row, "E").Value = sh.Cells(f.Row, "E").Value
Cells(Target.Row, "F").Value = sh.Cells(f.Row, "F").Value
Cells(Target.Row, "G").Value = sh.Cells(f.Row, "G").Value
Cells(Target.Row, "H").Value = sh.Cells(f.Row, "H").Value
Else
MsgBox "Member does not exists"
End If
End If
' Auto Date Paid
Dim Cell As Range
For Each Cell In Target
If Cell.Column = Range("B:B").Column Then
If Cell.Value <> "" Then
Cells(Cell.Row, "G").Value = Int(Now)
Else
Cells(Cell.Row, "G").Value = ""
End If
End If
Next Cell
' Auto Paid to
'Dim Cell As Range
For Each Cell In Target
If Cell.Column = Range("G:G").Column Then
If Cell.Value <> "" Then
Cells(Cell.Row, "H").Value = Int(Now + 14)
Else
Cells(Cell.Row, "H").Value = ""
End If
End If
Next Cell
End Sub
Thankyou in advance..
Last edited: