What is the purpose of this part of the code?
Private Sub Locator()
Application.ScreenUpdating = False
ASht = ActiveSheet.Name
ACell = CStr(ActiveCell.Address)
End Sub
Private Sub ReLocator()
Sheets(ASht).Select
Range(ACell).Select
Application.ScreenUpdating = True
End Sub
I am getting a Run-Time error '9':
Subscript out of range
shows highlighted
Current Code:
Issues:
1. listbox additem is adding like a text, I need to have columns and set the first column rows with a better understanding for end user
Title, Company,Lastname, Address, City, State, Zipcode with a auto adjust column size if possible?
2. output when data is select from listbox needs to be only on column B8,B9,B10, B11 not being added list a list when selected again.
Private Sub CommandButton3_Click()
UserForm1.Hide
UserForm2.Show
End Sub
Private Sub ListBox1_Click()
Locator
Sheets("Output").Select
Range("C5:C26").Select
Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
nr = ActiveCell.Row
CR = Left(ListBox1.Value, InStr(Trim(ListBox1.Value), " ") - 1) * 1
Sheets("Output").Range("C" & nr & ":E" & nr).Value = Sheets("Data").Range("B" & CR & ":D" & CR).Value
Sheets("Output").Range("F" & nr).Value = Sheets("Data").Range("G" & CR).Value
ListBox1.Visible = False
ReLocator
End Sub
Private Sub TextBox1_Change()
findname
End Sub
Private Sub findname()
Locator
If Len(TextBox1.Text) < 4 Then Exit Sub
Sheets("Data").Select
LR = Range("A95536").End(xlUp).Row
Set rngLook = Range(Cells(1, 2), Cells(LR, 1))
strValueToPick = TextBox1.Text
On Error Resume Next
'Find NAME IN COLUMN A
With rngLook
Set rngFind = .Find(strValueToPick, .Cells(1, 2), LookIn:=xlFormulas, LookAt:=xlWhole)
If Not rngFind Is Nothing Then
strFirstAddress = rngFind.Address
Set rngPicked = rngFind
Do
Set rngPicked = Union(rngPicked, rngFind)
Set rngFind = .FindNext(rngFind)
Loop While Not rngFind Is Nothing And rngFind.Address <> strFirstAddress
End If
End With
If strFirstAddress = "" Then Exit Sub
If Not rngPicked Is Nothing Then
rngPicked.Select
End If
ListBox1.Clear
For Each c In Selection
ListBox1.AddItem Cells(c, 1).Row & " " & Cells(c.Row, 2).Value & " " & Cells(c.Row, 3).Value & " " & Cells(c.Row, 4).Value & " " & Cells(c.Row, 5).Value & " " & Cells(c.Row, 6).Value & " " & Cells(c.Row, 7).Value
10 Next c
If ListBox1.ListCount = 1 Then ListBox1_Click
ReLocator
Changeflag = 0
End Sub
Private Sub Locator()
Application.ScreenUpdating = False
ASht = ActiveSheet.Name
ACell = CStr(ActiveCell.Address)
End Sub
Private Sub ReLocator()
Sheets(ASht).Select
Range(ACell).Select
Application.ScreenUpdating = True
End Sub
Bookmarks