Hello all! I am new to
vb, so this may seem like a very basic post. Or my coding may reflect my status as a
vb rookie, however, I come to you hoping for some help.
I am having the following issues.
I am trying to complete a "next" button on a userform so that once clicked it will seek the next applicable entry in my database. However I am VERY new to the
VB game still. The code I have is supposed to seek out the next applicable code from ONLY the visible cells. (As the page will already be filtered, unless you suggest putting it in this coding.) and then stop running and enter the found data into the corresponding userform objects. then when the button is pressed again, it is to run the code to get the next applicable data from the last found entry.and once all entries have been gone through, it is to display a message stating as such. however this code is having 2 seperate issues. ( I have stepped through, searched forums, tried and error'd, but still the same or more disastrous results.I am not posting this issue as a first resort, I am trying to learn this mostly on my own.) the 2 major issues are, 1) This code will go to the next item as long there are not more than 2 rows sperating them, otherwise it gives me the no further entries end script. And 2) It will not recognize the end of the filtered names and run the no further entries when i want it to. It simply skips down and fills the form in as blank entries. I would appreciate a little bit of explanation as to my issues, so that I can learn from this. Thank you in advance. The code is as follows....
Private Sub CommandButton7_Click()
Sheets("Segmentor").Select
Dim rng As Range, cell As Range
iName = UserForm23.ComboBox1.Value
Set rng = ActiveCell
For Each cell In rng
iBegin:
' check if row is visible - if so, get it
If ActiveCell.Offset(1, 0).EntireRow.Hidden = True Then
ActiveCell.Offset(1, 0).Select
GoTo iBegin:
Else
' process this row
If cell.Value = iName Then
ActiveCell.Offset(1, 0).Select
UserForm23.TextBox2.Value = ActiveCell.Offset(0, 1).Value
UserForm23.TextBox4.Value = ActiveCell.Offset(0, 5).Value
UserForm23.ComboBox2.Value = ActiveCell.Offset(0, 2).Value
UserForm23.ComboBox3.Value = ActiveCell.Offset(0, 3).Value
UserForm23.ComboBox4.Value = ActiveCell.Offset(0, 3).Value
Else
If Not cell.Value = iName Then
GoTo iEnd
Exit For
End If
End If
End If
Next
Exit Sub
iEnd:
MsgBox "No further entries found.", vbInformation + vbOKOnly, "Error"
End Sub
I also have another smaller, much less detailed question.
1) I have a combobox that is to display time increments in hour:min (ie; 12:00 AM, 3:00 PM), but it is showing in decimal form, is there code to format the textbox, such as .format(hh:mm), or .format = ("hh:mm") or something along those lines?"