dschenk832
New Member
- Joined
- Sep 5, 2018
- Messages
- 2
Hello All! Please forgive my complete lack of inexperience. I have never taken a class on writing excel macros and have so far been able to piece through what I have needed to do by intensive google searching, but I can not seem to get this code to work. When I hit play it doesn't actually give me an error message, but neither code is doing what I want. Any ideas? Also, I am not sure this method is the best for me. The search is by name, but it is possible for the name to be in the database multiple times (I work in public health and each record is an interaction therefore there could be multiple interactions), I was hoping to write code for a next button so the user can toggle through all of the different entries for that person and update as needed. Will that work?
Code for searching:
Private Sub Search_Click()
row_number = 0
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("GoalTracking").Range("B" & row_number)
If item_in_review = TextBox1.Value Then
TextBox5.Text = Sheets("GoalTracking").Range("A" & row_number)
TextBox2.Text = Sheets("GoalTracking").Range("C" & row_number)
ComboBox1.Text = Sheets("GoalTracking").Range("D" & row_number)
TextBox3.Text = Sheets("GoalTracking").Range("E" & row_number)
TextBox4.Text = Sheets("GoalTracking").Range("F" & row_number)
End If
Loop Until item_in_review = ""
End Sub
Code for updating:
Private Sub UpdateData_Click()
row_number = 0
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("GoalTracking").Range("B" & row_number)
If item_in_review = TextBox1.Text Then
Sheets("GoalTracking").Range("A" & row_number) = TextBox5.Text
Sheets("GoalTracking").Range("C" & row_number) = TextBox2.Text
Sheets("GoalTracking").Range("D" & row_number) = ComboBox1.Text
Sheets("GoalTracking").Range("E" & row_number) = TextBox3.Text
Sheets("GoalTracking").Range("F" & row_number) = TextBox4.Text
End If
Loop Until item_in_review = ""
End Sub
Any help will be GREATLY appreciated. my level of frustration is VERY high. Let me know if I can provide more information!
Code for searching:
Private Sub Search_Click()
row_number = 0
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("GoalTracking").Range("B" & row_number)
If item_in_review = TextBox1.Value Then
TextBox5.Text = Sheets("GoalTracking").Range("A" & row_number)
TextBox2.Text = Sheets("GoalTracking").Range("C" & row_number)
ComboBox1.Text = Sheets("GoalTracking").Range("D" & row_number)
TextBox3.Text = Sheets("GoalTracking").Range("E" & row_number)
TextBox4.Text = Sheets("GoalTracking").Range("F" & row_number)
End If
Loop Until item_in_review = ""
End Sub
Code for updating:
Private Sub UpdateData_Click()
row_number = 0
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("GoalTracking").Range("B" & row_number)
If item_in_review = TextBox1.Text Then
Sheets("GoalTracking").Range("A" & row_number) = TextBox5.Text
Sheets("GoalTracking").Range("C" & row_number) = TextBox2.Text
Sheets("GoalTracking").Range("D" & row_number) = ComboBox1.Text
Sheets("GoalTracking").Range("E" & row_number) = TextBox3.Text
Sheets("GoalTracking").Range("F" & row_number) = TextBox4.Text
End If
Loop Until item_in_review = ""
End Sub
Any help will be GREATLY appreciated. my level of frustration is VERY high. Let me know if I can provide more information!