I am in charge of keeping a record of the fees and payments in my club and so I decided to make an Excel page for it. I am new to Excel VBA programming, so I need some advice.
My idea is: if the person is present but didn't pay, I just mark an x, if he is present and just payed, I would like to be able to mark an N and make it so that a msgbox pops up asking the value of the payment and directly puts that value in a precise cell on another page.
Sub Pay()
Dim Pay As String
Pay = InputBox("Enter A New Payment", "Payment", "Enter amount here")
Range("'versement adherent'!C15").Value = Pay
End Sub
So that was my idea for the msgbox but it is too narrow, it only starts if asked to (doesn't start automatically when a cell with the value N is written) and the cell in which it writes the value is always the same.
Private Sub FindN(StrSearchQuery As String)
Set SearchRange = Range("versement adherent!F2:Y21")
FindN = StrSearchQuery
Function FindAll(SearchRange As Range, LookFor As String)
Dim FoundCell As Range
For Each area In SearchRange.Areas
With area
If .cell(.cell.Count).Row > MaxRow Then
MaxRow = .cell(.cell.Count).Column
End If
End With
Next area
Set lastcell = SearchRange.Worksheet.Cells(MaxRow, MaxCol)
Do Until True
Set FoundCell = SearchRange.Find(N)
If FoundCell = False Then
Exit Do
If FoundCell = True Then
For Each FoundCell In Worksheet("versement adherent").Range(FoundCell)
Range("versement adherent !Foundcell").Value = Pay
Range(FoundCell).Value = X
Exit Do
End If
End Function
Set FoundCell = FindAll
If FoundCell = True Then
For Each FoundCell In Worksheet("versement adherent").Range(FoundCell)
Range("versement adherent !Foundcell").Value = Pay
End If
I've tried adding some code to make the part where it finds a cell with the value N but it doesn't seem to work.