Hello ,
The macro below has been attached to a button on the "Daily Deposits". The attached workbook contains the button and the macro.
Sub RecordDeposits()
Dim Cell As Range
Dim DepDate As Range
Dim Rng As Range
Dim Wks As Worksheet
Set Rng = Worksheets("Daily Deposits").ListObjects(1).DataBodyRange
For Each Cell In Rng.Columns(2).Cells
If Not IsEmpty(Cell) Then
On Error Resume Next
Set Wks = ThisWorkbook.Worksheets(Cell.Text)
If Err = 9 Then
MsgBox "The worksheet '" & Cell.Text & "' was not found." & vbCrLf _
& "Please check the spelling and spaces.", vbExclamation
Err.Clear
Else
Set DepDate = Wks.Columns(2)
Set DepDate = DepDate.Find(Cell.Offset(0, -1).Text, , xlValues, xlWhole, xlByRows, xlPrevious, False, False, False)
If Not DepDate Is Nothing Then
DepDate.Offset(0, 3).Value = Cell.Offset(0, 1)
End If
End If
On Error GoTo 0
End If
Next Cell
End Sub
Bookmarks