목록 상자에서 선택된 항목의 행을 어떻게 찾을 수 있습니까?목록 상자에서 선택된 항목의 행 번호를 찾으십시오.
지금 내가 목록 상자에 발견 된 항목을 모두 입력하는 sub
을 가지고
Sub findnext()
Dim Name As String
Dim f As Range
Dim ws As Worksheet
Dim s As Integer
Dim findnext As Range
Set ws = ThisWorkbook.Worksheets("Master")
Name = surname.Value
ListBox1.Clear
Set f = Range("A:A").Find(what:=Name, LookIn:=xlValues)
Set findnext = f
Do
Debug.Print findnext.Address
Set findnext = Range("A:A").findnext(findnext)
ListBox1.AddItem findnext.Value
ListBox1.List(ListBox1.ListCount - 1, 1) = ws.Cells(findnext.Row, xFirstName).Value
ListBox1.List(ListBox1.ListCount - 1, 2) = ws.Cells(findnext.Row, xTitle).Value
ListBox1.List(ListBox1.ListCount - 1, 3) = ws.Cells(findnext.Row, xProgramAreas).Value
ListBox1.List(ListBox1.ListCount - 1, 4) = ws.Cells(findnext.Row, xEmail).Value
ListBox1.List(ListBox1.ListCount - 1, 5) = ws.Cells(findnext.Row, xStakeholder).Value
ListBox1.List(ListBox1.ListCount - 1, 6) = ws.Cells(findnext.Row, xofficephone).Value
ListBox1.List(ListBox1.ListCount - 1, 7) = ws.Cells(findnext.Row, xcellphone).Value
'ListBox1.List(ListBox1.ListCount - 1, 8) = ws.Cells(findnext.Row, xFirstName).Value
Loop While findnext.Address <> f.Address
End Sub
아래를 참조하고 사용자가 목록 상자에서 항목을 선택하면, 다음은에 정보를 채우는 것 사용자 정의 폼 나는 목록 상자에서 선택한 항목의 행 번호를 확인하는 방법을 ListBox1_click()
에서 파악하려는
Sub ListBox1_Click()
surname.Value = ListBox1.List(ListBox1.ListIndex, 0)
firstname.Value = ListBox1.List(ListBox1.ListIndex, 1)
tod.Value = ListBox1.List(ListBox1.ListIndex, 2)
program.Value = ListBox1.List(ListBox1.ListIndex, 3)
email.Value = ListBox1.List(ListBox1.ListIndex, 4)
SetCheckBoxes ListBox1.List(ListBox1.ListIndex, 5) '<<<< added
officenumber.Value = ListBox1.List(ListBox1.ListIndex, 6)
cellnumber.Value = ListBox1.List(ListBox1.ListIndex, 7)
End Sub
의 텍스트 상자. 일단 내가 이것을 알아 내면 update sub
코드를 작성하여 선택한 항목의 행 번호를 찾고 텍스트 상자에 정보를 다시 입력하고 행 정보를 업데이트합니다.
find
을 숨겨진 워크 시트의 행 번호를 저장하는 생각 ..하지만 난 희망
listbox
에서 선택되어 있는지와 found
의 행 번호를 연결하는 방법을 모른다 .. 이게 의미가있어, 그렇지 않으면 알려줘!
그래서'debug.print' 대신에 다음과 같이 썼습니다 :'worksheets ("hs"). cells (1,1) = r' 그리고 당신에게 제공 한 다음 코드를 사용했습니다. 'hs'에서 1의 값. 'hs'는 선택된 항목의 행 번호를 저장하고자하는 숨겨진 시트입니다. 문제는, 그것은 나에게 목록 상자에서 행 번호를 주며, 행 번호는 Excel 스프레드 시트에서 찾을 수있다. 예를 들어,'apple'이라는 항목이 있고'search'를하고 apple을 찾으면 apple에 관한 모든 정보를'listbox'에 입력합니다. 내 질문에 어떻게'행 상자를'사과'목록 상자에서 선택했을 때 찾을 수 있습니까? 말이 돼...? – Doolie1106
"목록 상자에서 선택한 항목의 행 번호를 어떻게 결정할 수 있습니까?"라는 질문을하셨습니까? ListBox에 포함 된 워크 시트 셀을 클릭 할 때 저장/찾으려고합니까? – PatricK
예, 목록 상자에서 클릭하면 워크 시트에있는 항목의 행 번호를 찾으려고합니다. 리스트 박스는'find' 함수 다음에 채워집니다. 그래서리스트 박스에서 클릭 한 후에'found' 아이템의 행 번호를 찾고 싶습니다. – Doolie1106