help adjusting error transfer data from userform to worksheet

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,429
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
i appreciate if anybody can help me i have error" compile error" , can't find project or library i have sheet contains data from a2:at1000 and userform contains many textbox
it gives me highlight in this line
If Len(Trim(Me.Controls(Ad).Value)) = 0 Then
especially this word "Trim"
VBA Code:
Private Sub ButtonNew_Click()
Dim Ad As String
Dim c As Integer
Dim xx As Long
''''''''''''''''''''
For c = 1 To ContColmn
    Ad = Cells(1, c).Address(0, 0)
    If Len(Trim(Me.Controls(Ad).Value)) = 0 Then
       MsgBox "address: " & Me.Controls("xx" & c).Caption & " empty", vbCritical + vbMsgBoxRight + vbMsgBoxRtlReading, "empty cell"
       Me.Controls(Ad).SetFocus
        Exit Sub
  End If
Next
''''''''''''''''''''''
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
With Sheet2
    Lr = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
    For c = 1 To ContColmn
        Ad = Cells(1, c).Address(0, 0)
        .Cells(Lr, c).Value = Me.Controls(Ad).Value
    Next
End With
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
A1.Value = Application.WorksheetFunction.Max(Sheets(2).Range("A2:A5000")) + 1
MsgBox "ok"
End Sub
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I guess it is an ActiveX button on a worksheet rather than a control on a form.
So you cannot refer to Controls collection on a worksheet. This is the reason for the error.
Check this: Using ActiveX Controls on Sheets
 
Upvote 0
i search this error in internet and suggestion is unchecked this tool from reference "missing type library then it changes the error message "could not find the specified object"
 
Upvote 0

Forum statistics

Threads
1,214,838
Messages
6,121,885
Members
449,057
Latest member
Moo4247

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