Patriot2879
Well-known Member
- Joined
- Feb 1, 2018
- Messages
- 1,259
- Office Version
- 2010
- Platform
- Windows
Hi I hopeyou can help, I am trying to make a post code lookup, so for example inTextBox51 you type in your postcode like ‘WR5 3’ then automatically it updates textbox52 with the area of the postcode for example ‘Worcester’. It gets the data from my sheet called ‘PostCode’and looks at row A for the Postcode and row B is the area, I have made a module below called ‘GetData’ but it is not working, and In the sub for textbox51 I have put in GetData for it to goto the module.
My codingis below hope you can help.
My codingis below hope you can help.
Code:
Option Explicit
Code:
[FONT=Calibri][SIZE=3][COLOR=#000000]Dim id As String, i As Long, j As Integer, flag As Boolean[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Sub GetData()
Dim Rw As Variant
If Len(UserForm1.TextBox51.Value) > 0 Then
flag = False
id = UserForm1.TextBox51.Value
Rw = Application.Match(id, Sheets("PostCode").Range("A2:A9316"), 0)
If Not IsError(Rw) Then
flag = True
For j = 1 To 1
UserForm1.Controls("TextBox52" & j).Value = ThisWorkbook.Worksheets("PostCode").Cells(Rw, j).Value
Next j
End If
If flag = False Then
For j = 1 To 1
UserForm1.Controls("TextBox52" & j).Value = ""
Next j
End If
Else
End If
End Sub[/COLOR][/SIZE][/FONT]
Last edited: