I'm stuck and would like a hand on putting me in the right direction for parallel arrays.
Question is " use parallel arrays to load the Last name and row number or first cell in the row. Sort both arrays based on the Last name array (every time a last name is moved also move its corresponding row number in its array)"
Here is what i got so far.
UserForm
Private Sub cmdSubmit_Click()
Dim wks As Worksheet
Set wks = ThisWorkbook.Sheets("Customer Entry")
nr = wks.Cells(Rows.Count, 1).End(xlUp).Row + 1
wks.Cells(nr, 1) = Me.txtFirstName
wks.Cells(nr, 2) = Me.txtLastName
wks.Cells(nr, 3) = Me.txtAddress
wks.Cells(nr, 4) = Me.txtCity
wks.Cells(nr, 5) = Me.txtState
wks.Cells(nr, 6) = Me.txtZipCode
wks.Cells(nr, 7) = Me.txtEmail
wks.Cells(nr, 8) = CInt(Me.txtPhone)
End Sub
What I got for a Array which is wrong.
Private Sub cmdSort_Click()
Dim tempVar As Integer
Dim Continue As Boolean
Dim myArray(10) As Integer
Dim I As Integer
For I = 2 To 11
myArray(I - 2) = Cells(I, "B").Value
Next I
Do
Continue = False
For I = 0 To 9
If myArray(I) > myArray(I + 1) Then
tempVar = myArray(I)
myArray(I) = myArray(I + 1)
myArray(I + 1) = tempVar
End If
Next I
Loop While Continue = True
Range("A1").Value = "Sorted Names"
For I = 2 To 11
Cells(I, "B").Value = myArray(I - 1)
Next I
End Sub
Like I said earlier I just want some help on being pointed in the right direction.
Thanks in advance.
Other site i posted on : Click Here!
Bookmarks