#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 267
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 267
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
command button add another command Wanna Learn Excel Discussion (Misc queries) 5 December 7th 08 11:42 PM
Command Button inspirz Excel Discussion (Misc queries) 1 March 29th 07 06:38 PM
Command Button tom Excel Worksheet Functions 0 November 3rd 06 11:37 AM
Command Button Steved Excel Worksheet Functions 2 February 19th 06 11:01 PM
command button abfabrob Excel Discussion (Misc queries) 5 October 7th 05 12:54 AM


All times are GMT +1. The time now is 12:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"