Dynamic TextBox with changing values

iamtheone

New Member
Joined
Oct 23, 2018
Messages
1
Hi,

I'm trying to create a Userform with TextBox1 already there. I have a table of data and need to apply the filter for a specific value and then add textboxes as per the count of filtered values. In each text box, needs the value of the cell next in the column. Here's my code.

Private Sub CommandButton1_Click()
Selection.AutoFilter
Range("F1").Select
ActiveSheet.Range("$A$1:$I$14").AutoFilter Field:=6, Criteria1:=TextBox1.Value
Range("F1").Select
Dim cCntrl As Control
Dim b As Range
Dim c As Integer
Set b = Range("A:A")
Range("AZ1").Value = WorksheetFunction.Subtotal(3, b)
For a = 1 To Range("AZ1").Value - 1
Set c = WorksheetFunction.Sum(a, 1)
Set cCntrl = Me.Controls.Add("Forms.TextBox." & c, "MyTextBox", True)
With cCntrl
.Width = 150
.Height = 15
.Top = 10 * 2 * a
.Left = 10
.ZOrder (0)
End With
ActiveCell.Offset(1, 0).Select
Do Until ActiveCell.EntireRow.Hidden = False
ActiveCell.Offset(1, 0).Select
Loop
TextBox& c.Value = ActiveCell.Value
Next a
Selection.AutoFilter
End Sub


I'm getting an error "Object Required" for "Set c = a + 1"

Not able to understand why. Please help! :-(
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,224,828
Messages
6,181,201
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top