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

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,215,353
Messages
6,124,458
Members
449,161
Latest member
NHOJ

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