This is all done in Excel 2000
I keep getting this error: "Unable to get the find property of the range class".
I have one workbook with 3 sheets on it. I have 3 ActiveX ComboBoxes, one of which is dependent on the other.
Sheet 1 is my "form" where the ActiveX ComboBoxes are.
Sheet 2 is called "Data" and it's where I pull data from and copy to Sheet3 to populate the ComboBoxes. (Only way I knew how to do this. I'm new to VBA).
Column A looks like this:
(List of Builders)
Centex
Centex
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
Keith Builders
Lennar
Lennar
Lennar
Lennar
Lennar
Lennar
Lennar
Lennar
Lennar
Lennar
Lennar
Morrison
Morrison
Morrison
Morrison
Column B looks like this:
(List of Subdivisions)
Trailside
Westview Meadows
Canyon Creek
Georgetown Village
Great Hills
Heritage Park
Loma Vista
Marble Falls
Oakland Village
Pioneer Crossing
Ridgewood S/R
Riverplace
Senna Hills
Shady Hollow
Steiner Westridge
Stone Canyon
Fubar
Amberwood
Chandler Creek
Enclave at Brushy Creek
Forest Oaks
Georgetown Village
Greenbury Estates
Hutto Park
Legends of Hutto
Prairie on the Creek
Summer Crest
Wild Horse Ranch
Deer Creek Ranch
Rio Mesa
Steiner Westridge
Wood Glen
I have a button on this sheet that puts a unique list of builders to Sheet3:ColumnA. That code looks like this:
Sub Button1_Click()
Worksheets("Data"
.Range("A2:B1000"
.Sort _
Key1:=Worksheets("Data"
.Range("A2"
, _
Key2:=Worksheets("Data"
.Range("B2"
, _
Order2:=xlAscending
Worksheets("Data"
.Range("C2:C1000"
.Sort _
Key1:=Worksheets("Data"
.Range("C2"
Worksheets("Data"
.Range("D2
1000"
.Sort _
Key1:=Worksheets("Data"
.Range("D2"
Dim UniqueBuilders As Range
Set UniqueBuilders = Range("Data!A2:A1000"
Set CopyToRange = Range("Sheet3!A1"
UniqueBuilders.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=(CopyToRange), Unique:=True
End Sub
This code is also referenced in the Workbook_SheetActivate. Code looks like this: (ignore the comments, I'm trying a few things to get this work consistently).
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Module1.Button1_Click
End Sub
Sheet 3 is where the ranges (columns) are used to populate the 3 ComboBoxes.
Here's the code that populates ComboBox2 based on the selection by the user of ComboBox1:
Private Sub ComboBox1_Change()
Dim dd_choice As String
Dim firstAddress, lastAddress, temp1, temp2, temp3, temprng As String
dd_choice = Sheets("Sheet1"
.ComboBox1.Value
'Sheets(Datasheet).Columns(1).Find(What:=FirstComp, LookIn:=xlValues).Activate
' firstrow = ActiveCell.Row + 1
With Sheets("Data"
.Range("A2:A71"
Set c = .Find(What:=dd_choice, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
lastAddress = c.Address
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
'With Sheets("Data"
.Columns(1)
' .Activate
' Set c = .Find(What:=dd_choice, LookIn:=xlValues)
' If Not c Is Nothing Then
' firstAddress = c.Address
' Do
' lastAddress = c.Address
' Set c = .FindNext(c)
' Loop While Not c Is Nothing And c.Address <> firstAddress
' End If
'End With
temp1 = "B" & Right(firstAddress, Len(firstAddress) - 3)
temp2 = "B" & Right(lastAddress, Len(lastAddress) - 3)
temp3 = temp1 & ":" & temp2
Worksheets("Sheet3"
.Range("b1:b1000"
.Value = ""
If temp1 = temp2 Then
Worksheets("Sheet3"
.Range("B1"
.Value = Worksheets("Data"
.Range(temp1).Value
Else
temprng = Trim(Str(Val(Right(lastAddress, Len(lastAddress) - 3)) - Val(Right(firstAddress, Len(firstAddress) - 3)) + 1))
Worksheets("Sheet3"
.Range("B1:B" & temprng).Value = Worksheets("Data"
.Range(temp3).Value
End If
End Sub
Now, this code, ComboBox1_Change(), works, but it fires whenever Workbook_SheetActivate(ByVal Sh As Object) fires. I don't understand why. This is where I get the "Unable to get the find property of the range class" error. When ComboBox1_Change() is moved to it's own module (like Module2, it's currently on Sheet1(Sheet1)), It doesn't fire when you change ComboBox1.
If anyone could help me out with this, I'd sure appreciate it!
Thanks in advance!
Best Regards,
Kalecomm.
I keep getting this error: "Unable to get the find property of the range class".
I have one workbook with 3 sheets on it. I have 3 ActiveX ComboBoxes, one of which is dependent on the other.
Sheet 1 is my "form" where the ActiveX ComboBoxes are.
Sheet 2 is called "Data" and it's where I pull data from and copy to Sheet3 to populate the ComboBoxes. (Only way I knew how to do this. I'm new to VBA).
Column A looks like this:
(List of Builders)
Centex
Centex
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
David Weekley
Keith Builders
Lennar
Lennar
Lennar
Lennar
Lennar
Lennar
Lennar
Lennar
Lennar
Lennar
Lennar
Morrison
Morrison
Morrison
Morrison
Column B looks like this:
(List of Subdivisions)
Trailside
Westview Meadows
Canyon Creek
Georgetown Village
Great Hills
Heritage Park
Loma Vista
Marble Falls
Oakland Village
Pioneer Crossing
Ridgewood S/R
Riverplace
Senna Hills
Shady Hollow
Steiner Westridge
Stone Canyon
Fubar
Amberwood
Chandler Creek
Enclave at Brushy Creek
Forest Oaks
Georgetown Village
Greenbury Estates
Hutto Park
Legends of Hutto
Prairie on the Creek
Summer Crest
Wild Horse Ranch
Deer Creek Ranch
Rio Mesa
Steiner Westridge
Wood Glen
I have a button on this sheet that puts a unique list of builders to Sheet3:ColumnA. That code looks like this:
Sub Button1_Click()
Worksheets("Data"
Key1:=Worksheets("Data"
Key2:=Worksheets("Data"
Order2:=xlAscending
Worksheets("Data"
Key1:=Worksheets("Data"
Worksheets("Data"
Key1:=Worksheets("Data"
Dim UniqueBuilders As Range
Set UniqueBuilders = Range("Data!A2:A1000"
Set CopyToRange = Range("Sheet3!A1"
UniqueBuilders.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=(CopyToRange), Unique:=True
End Sub
This code is also referenced in the Workbook_SheetActivate. Code looks like this: (ignore the comments, I'm trying a few things to get this work consistently).
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Module1.Button1_Click
End Sub
Sheet 3 is where the ranges (columns) are used to populate the 3 ComboBoxes.
Here's the code that populates ComboBox2 based on the selection by the user of ComboBox1:
Private Sub ComboBox1_Change()
Dim dd_choice As String
Dim firstAddress, lastAddress, temp1, temp2, temp3, temprng As String
dd_choice = Sheets("Sheet1"
'Sheets(Datasheet).Columns(1).Find(What:=FirstComp, LookIn:=xlValues).Activate
' firstrow = ActiveCell.Row + 1
With Sheets("Data"
Set c = .Find(What:=dd_choice, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
lastAddress = c.Address
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
'With Sheets("Data"
' .Activate
' Set c = .Find(What:=dd_choice, LookIn:=xlValues)
' If Not c Is Nothing Then
' firstAddress = c.Address
' Do
' lastAddress = c.Address
' Set c = .FindNext(c)
' Loop While Not c Is Nothing And c.Address <> firstAddress
' End If
'End With
temp1 = "B" & Right(firstAddress, Len(firstAddress) - 3)
temp2 = "B" & Right(lastAddress, Len(lastAddress) - 3)
temp3 = temp1 & ":" & temp2
Worksheets("Sheet3"
If temp1 = temp2 Then
Worksheets("Sheet3"
Else
temprng = Trim(Str(Val(Right(lastAddress, Len(lastAddress) - 3)) - Val(Right(firstAddress, Len(firstAddress) - 3)) + 1))
Worksheets("Sheet3"
End If
End Sub
Now, this code, ComboBox1_Change(), works, but it fires whenever Workbook_SheetActivate(ByVal Sh As Object) fires. I don't understand why. This is where I get the "Unable to get the find property of the range class" error. When ComboBox1_Change() is moved to it's own module (like Module2, it's currently on Sheet1(Sheet1)), It doesn't fire when you change ComboBox1.
If anyone could help me out with this, I'd sure appreciate it!
Thanks in advance!
Best Regards,
Kalecomm.