Hi,
This is what I am trying to do... 
unhide few texboxes if their names are present in any cells between A1:Z1.. if textbox names are not present then hide textbox. If all cells are blank then hide all textboxes.
Thanks
Suji
Hi there,
 
Presuming you mean activex textboxes, maybe something like:
 
Option Explicit
    
Private Sub CommandButton1_Click()
Dim obj         As OLEObject
Dim arrNames    As Variant
Dim n           As Long
    
    arrNames = Me.Range("A1:Z1").Value
    For n = 1 To UBound(arrNames, 2)
        arrNames(1, n) = LCase(Trim(arrNames(1, n)))
    Next
    
    For Each obj In Me.OLEObjects
        If TypeName(obj.Object) = "TextBox" Then
            obj.Visible = _
                Not IsError(Application.Match(LCase(obj.Name), Application.Index(arrNames, 1, 0), 0))
        End If
    Next
End Sub
    
Private Sub CommandButton2_Click()
Dim obj         As OLEObject
    
    For Each obj In Me.OLEObjects
        If TypeName(obj.Object) = "TextBox" Then
            obj.Visible = True
        End If
    Next
End Sub
 
I wasn't sure, but guessed that we would like to keep it case-insensitive.
 
Hope that helps,
 
Mark
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.