Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
D D is offline
external usenet poster
 
Posts: 121
Default Sorting 2 Linked Arrays [Retry]

I tried posting this last week and never got a reponse, so I thought I would try again now that the holidays are over:

I'm currently using the code below to create a goto userform in an excel spreadsheet. This works fine if the sheet is sorted by the Job Name, but it may not always be. So, what'd I'd like to do is sort the two arrays. The first by job #, the second by Job name, but still have them be linked together, so that a job can be found by either the # or the name, and the other matching component can be seen. The way it works now, you can enter in the job #, and then see the matching job name, or vice versa, then click okay and be taken to that job in the spreadsheet. I would like to keep that functionality. Just using matching listindexes, as I'm doing now, would not work upon sorting. Thanks for any help.

Option Explicit
Dim jobnum()
Dim jobname()
Dim i As Long
Dim temppos As Integer

Private Sub CancelBut_Click()
Unload GotoJobForm
End Sub

Private Sub cmbJobName_Change()
cmbJobNum.ListIndex = cmbJobName.ListIndex
End Sub

Private Sub cmbJobNum_Change()
cmbJobName.ListIndex = cmbJobNum.ListIndex
End Sub

Private Sub OkayBut_Click()
Rows(cmbJobName.ListIndex + 3).EntireRow.Select
Unload GotoJobForm
End Sub

Private Sub UserForm_Initialize()
ReDim jobnum(3 To ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row)
ReDim jobname(3 To ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row)
For i = 3 To ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
jobnum(i) = Rows(i).Columns("A").Value
Next
For i = 3 To ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
temppos = InStr(1, Rows(i).Columns("B").Value, Chr(10), vbTextCompare)
If temppos < 0 Then
jobname(i) = Left(Rows(i).Columns("B").Value, temppos - 1)
Else
jobname(i) = Rows(i).Columns("B").Value
End If
Next
For i = 3 To ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
cmbJobNum.AddItem jobnum(i)
cmbJobName.AddItem jobname(i)
Next
SendKeys "{tab}"
SendKeys "+{tab}"
End Sub








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting non-linked cells in a linked worksheet Gary Excel Discussion (Misc queries) 1 October 25th 08 03:38 AM
Switch To/Retry message appears Kim Doran Excel Programming 0 February 4th 04 11:21 AM
Sorting Arrays B Tuohy Excel Programming 3 January 27th 04 04:22 AM
List boxes, Arrays and Sorting Stuart[_15_] Excel Programming 2 December 23rd 03 06:49 PM
VBA: Sorting arrays in hierarchichal data structu Help!!! Karen Lee Excel Programming 6 September 24th 03 05:14 PM


All times are GMT +1. The time now is 05:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"