![]() |
command button sub
Hi why wont this work for a command button, what should I write instead?
Private Sub CommandButton3_Click() If Not Intersect(Target, Range("patientlist")) Is Nothing Then UserForm2.TextBox1.Value = ActiveCell.Value UserForm2.Show End If End Sub |
command button sub
What is target? Event subs have target as a parameter. Yours does not define
target anywhere. Perhaps activecell Private Sub CommandButton3_Click() If Not Intersect(activcell, Range("patientlist")) Is Nothing Then UserForm2.TextBox1.Value = ActiveCell.Value UserForm2.Show End If End Sub -- HTH... Jim Thomlinson "Atishoo" wrote: Hi why wont this work for a command button, what should I write instead? Private Sub CommandButton3_Click() If Not Intersect(Target, Range("patientlist")) Is Nothing Then UserForm2.TextBox1.Value = ActiveCell.Value UserForm2.Show End If End Sub |
command button sub
This code should go into Worksheet_Change(ByVal Target As Range) or
Worksheet_SelectionChange(ByVal Target As Range) events. Test what the 'Target' is when you click on the button... "Atishoo" wrote: Hi why wont this work for a command button, what should I write instead? Private Sub CommandButton3_Click() If Not Intersect(Target, Range("patientlist")) Is Nothing Then UserForm2.TextBox1.Value = ActiveCell.Value UserForm2.Show End If End Sub |
command button sub
thank you!!
"Jim Thomlinson" wrote: What is target? Event subs have target as a parameter. Yours does not define target anywhere. Perhaps activecell Private Sub CommandButton3_Click() If Not Intersect(activcell, Range("patientlist")) Is Nothing Then UserForm2.TextBox1.Value = ActiveCell.Value UserForm2.Show End If End Sub -- HTH... Jim Thomlinson "Atishoo" wrote: Hi why wont this work for a command button, what should I write instead? Private Sub CommandButton3_Click() If Not Intersect(Target, Range("patientlist")) Is Nothing Then UserForm2.TextBox1.Value = ActiveCell.Value UserForm2.Show End If End Sub |
All times are GMT +1. The time now is 08:25 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com