PDA

View Full Version : UserForm Caption text with a cell ...



Esmatullah
02-04-2013, 07:17 PM
Hi dear Friends!
I need a way of a userform code that connect or link text of a cell like A1 of sheet1 to userform caption text.
I mean the when i type in cell A1 Good the userform caption must set Good. Thanks plz help me.

mikerickson
02-04-2013, 11:45 PM
You could put this in the sheet's code module

Private Sub Worksheet_Change(ByVal Target As Range)
Dim keyRange As Range
Set keyRange = Range("A1")

On Error Resume Next
Set keyRange = Application.Intersect(keyRange, keyRange.Precedents)
On Error GoTo 0

If Not Nothing Is Application.Intersect(Target, keyRange) Then
UserForm1.Caption = keyRange.Cells(1, 1).Text
End If
End Sub

Esmatullah
02-05-2013, 04:11 AM
Thanks.
But I have Five userforms named userform1, userform2 and so on. I want to apply A1 cell for userform1, A2 cell for userform2 and so on for their caption titles. Thanks please help. and also it must apply in whole workbook. I mean when i open this userform in every sheets it must names Sheet1 Range(A1). Please Help.

Esmatullah
02-05-2013, 07:20 PM
Plz Help some one.