Kelly05201
New Member
- Joined
- Jun 17, 2016
- Messages
- 29
Hello all.. learning this vba stuff one google search at a time is tough! I'm knee deep into a project that's well beyond my skill set.. but learning fast. The trouble I'm having is how to reference other cells in proper syntax.. and understanding how to specify a range... can someone get me on the right track?
Workbook for my horse club.
My code so far:
Sheet name: "Registration" (The sub will reside in this sheet module)
*note: Cells A1, B1, C1, D1, and E1 are the only cells in the whole sheet that aren't dynamic. All other cell values change daily.
<tbody>
</tbody>
The purpose of the sub() is to check the event sheets for the existence of a proper rider and horse entry... kind of self explanatory, but I'm showing the sheets after the sub runs for clarity...
Sheet name: "Adult POLES" (one of 21 possible division & event sheet names)
<tbody>
</tbody>Sheet name: "Youth BALL AND CHAIN" (Another of 21 possible division & event sheet names)
<tbody>
</tbody>
Many thanks to those who took the time to read, and bigger thanks to anyone who can help get me on track !
Workbook for my horse club.
My code so far:
Code:
Private Sub Worksheet_SelectionChange(ByVal target As Range)
On Error Resume Next
If Not Intersect(target, Range("A2:L70")) Is Nothing Then
Dim SheetTarget As Worksheet
Dim Registration As Worksheet
Dim HorseNumber As Range
Dim cell As Range
Dim EntryVerified As Boolean
Const RegistrationName = "Registration"
Dim LastRow As Long
LastRow = TargetSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
For Each cell In Registration.Range("F2:L70") 'test each cell for exisitng matches on TargetSheet
SheetTarget = ""
If IsEmpty(cell) = False Then 'rider has entered that event, cell value indicates division
SheetTarget = cell.Value & " " '& [value of row 1 @ same column]
'CHECK FOR AN EXACT MATCH ON TargetSheet OF ALL: HORSE NUMBER ("D"), FIRST NAME ("A") AND LAST NAME ("B")
'For Each HorseNumber in range(SheetTarget("D2:D70"))
EntryVerified = False
'If HorseNumber = Registration.cell("E" & Row()) And
'HorseNumber("A" & Row()) = cell("A" & Row()) And
'HorseNumber("B" & Row()) = cell("B" & Row()) Then
EntryVerified = True
Exit For
End If
If EntryVerified = False Then
cell.Offset("A" & Row()).Copy (SheetTarget("A" & LastRow)) 'rider's first name
cell.Offset("B" & Row()).Copy (SheetTarget.Range("B" & LastRow)) 'rider's last name
cell.Offset("C" & Row()).Copy (SheetTarget.Range("C" & LastRow)) 'horse name
cell.Offset("E" & Row()).Copy (SheetTarget.Range("D" & LastRow)) 'horse ID number
End If
Next HorseNumber
End If
Next cell
End If
End Sub
Sheet name: "Registration" (The sub will reside in this sheet module)
*note: Cells A1, B1, C1, D1, and E1 are the only cells in the whole sheet that aren't dynamic. All other cell values change daily.
A | B | C | D | E | F | G | H | I | J | K | L | |
1 | FIRST NAME | LAST NAME | HORSE NAME | ...... | HORSE TAG # | POLES | BARRELS | FIGURE 8 | SPEAR RINGS | BALL AND CHAIN | KEYHOLE | ZIG ZAG |
2 | SUSIE | SMITH | VIPER | 55 | Adult | Adult | Adult | |||||
3 | SALLY | SMITH | SABER | 41 | Adult | Adult | Adult | Adult | Adult | |||
4 | KAREN | MILLER | KARMA | 29 | Youth | Youth | ||||||
5 | BILL | BARKER | ACE | 22 | Jack Benny | Jack Benny | Jack Benny | |||||
6 | KAREN | MILLER | ACE | 22 | Youth | Youth | Youth | Youth | ||||
.... | ||||||||||||
70 | JOE | JOHNSON | JACKO | 88 | Jack Benny |
<tbody>
</tbody>
The purpose of the sub() is to check the event sheets for the existence of a proper rider and horse entry... kind of self explanatory, but I'm showing the sheets after the sub runs for clarity...
Sheet name: "Adult POLES" (one of 21 possible division & event sheet names)
A | B | C | D | E | F | G | |
1 | FIRST NAME | LAST NAME | HORSE NAME | HORSE TAG # | ... | ... | ... |
2 | SUSIE | SMITH | VIPER | 55 | |||
3 | SALLY | SMITH | SABER | 41 | |||
... | |||||||
70 |
<tbody>
</tbody>
A | B | C | D | E | F | G | |
FIRST NAME | LAST NAME | HORSE NAME | HORSE TAG # | ... | ... | ... | |
1 | KAREN | MILLER | KARMA | 29 | ... | ... | ... |
2 | KAREN | MILLER | ACE | 22 | |||
3 | |||||||
... | |||||||
70 |
<tbody>
</tbody>
Many thanks to those who took the time to read, and bigger thanks to anyone who can help get me on track !