Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 276
Default Use 1 userform for many sheets, Rather than 1 userform per sheet: How?

The below is the code that i am using to display and update values in cells:
X3 & X6 on a sheet.
I have the rows and columns hiden from view, but the user can see the
current and modify if need by by using the userform.
However rather than creating a userform for each person, how can i use the 1
userform to look at the SAME cells (X3 & X6) DEPENDING on what sheet the
userform was run from????

I though the simple:
ACTIVESHEET.SELECT would do it but it seems to only look to the same sheet.






Private Sub CommandButton1_Click()
activessheet.select
If Me.TextBox2.Value < "" Then
Range("X3").Value = Me.TextBox2.Value
End If
If Me.TextBox4.Value < "" Then
Range("X6").Value = Me.TextBox4.Value
End If
UserForm2.Hide
MsgBox "The amounts have been Renewed.", , "title...."
End Sub

Private Sub CommandButton2_Click()
UserForm2.Hide
End Sub

Private Sub Frame1_Click()

End Sub

Private Sub TextBox1_Change()
With Me.TextBox1
End With
End Sub

Private Sub TextBox2_Change()
End Sub

Private Sub TextBox3_Change()
End Sub

Private Sub TextBox4_Change()
End Sub

Private Sub UserForm_Initialize()
ActiveSheet.Select
With Me.TextBox1
.ControlSource = "X3"
End With
With Me.TextBox3
.ControlSource = "X6"
End With

End Sub



Regards


Corey....


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Use 1 userform for many sheets, Rather than 1 userform per sheet: How?

The unqualified range would assume the ActiveSheet.
Put a command button on a WS and add this code. select different worksheets
and see that the range is updated, whichever sheet is active.

<WS code
Private Sub CommandButton1_Click()
UserForm1.Show vbModeless
End Sub
</WS code

<userform code
Private Sub UserForm_Click()
Range("A1").Value = "Value Added"
End Sub
</userform code

NickHK

"Corey" wrote in message
...
The below is the code that i am using to display and update values in

cells:
X3 & X6 on a sheet.
I have the rows and columns hiden from view, but the user can see the
current and modify if need by by using the userform.
However rather than creating a userform for each person, how can i use the

1
userform to look at the SAME cells (X3 & X6) DEPENDING on what sheet the
userform was run from????

I though the simple:
ACTIVESHEET.SELECT would do it but it seems to only look to the same

sheet.






Private Sub CommandButton1_Click()
activessheet.select
If Me.TextBox2.Value < "" Then
Range("X3").Value = Me.TextBox2.Value
End If
If Me.TextBox4.Value < "" Then
Range("X6").Value = Me.TextBox4.Value
End If
UserForm2.Hide
MsgBox "The amounts have been Renewed.", , "title...."
End Sub

Private Sub CommandButton2_Click()
UserForm2.Hide
End Sub

Private Sub Frame1_Click()

End Sub

Private Sub TextBox1_Change()
With Me.TextBox1
End With
End Sub

Private Sub TextBox2_Change()
End Sub

Private Sub TextBox3_Change()
End Sub

Private Sub TextBox4_Change()
End Sub

Private Sub UserForm_Initialize()
ActiveSheet.Select
With Me.TextBox1
.ControlSource = "X3"
End With
With Me.TextBox3
.ControlSource = "X6"
End With

End Sub



Regards


Corey....




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 276
Default Use 1 userform for many sheets, Rather than 1 userform per sheet: How?

Sorry Nick i do not understand what you mean ???

If i enter values intot he userform2 the values do not correspond to the
sheet i run the userform from they always refer to the values on the same
sheet.

Corey....
"NickHK" wrote in message
...
The unqualified range would assume the ActiveSheet.
Put a command button on a WS and add this code. select different
worksheets
and see that the range is updated, whichever sheet is active.

<WS code
Private Sub CommandButton1_Click()
UserForm1.Show vbModeless
End Sub
</WS code

<userform code
Private Sub UserForm_Click()
Range("A1").Value = "Value Added"
End Sub
</userform code

NickHK

"Corey" wrote in message
...
The below is the code that i am using to display and update values in

cells:
X3 & X6 on a sheet.
I have the rows and columns hiden from view, but the user can see the
current and modify if need by by using the userform.
However rather than creating a userform for each person, how can i use
the

1
userform to look at the SAME cells (X3 & X6) DEPENDING on what sheet the
userform was run from????

I though the simple:
ACTIVESHEET.SELECT would do it but it seems to only look to the same

sheet.






Private Sub CommandButton1_Click()
activessheet.select
If Me.TextBox2.Value < "" Then
Range("X3").Value = Me.TextBox2.Value
End If
If Me.TextBox4.Value < "" Then
Range("X6").Value = Me.TextBox4.Value
End If
UserForm2.Hide
MsgBox "The amounts have been Renewed.", , "title...."
End Sub

Private Sub CommandButton2_Click()
UserForm2.Hide
End Sub

Private Sub Frame1_Click()

End Sub

Private Sub TextBox1_Change()
With Me.TextBox1
End With
End Sub

Private Sub TextBox2_Change()
End Sub

Private Sub TextBox3_Change()
End Sub

Private Sub TextBox4_Change()
End Sub

Private Sub UserForm_Initialize()
ActiveSheet.Select
With Me.TextBox1
.ControlSource = "X3"
End With
With Me.TextBox3
.ControlSource = "X6"
End With

End Sub



Regards


Corey....






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Use 1 userform for many sheets, Rather than 1 userform per sheet: How?

As you are hiding (rather than unloading) the userform, the initialisation
event only gets fired once. So the .ControlSource does not change.
So either unload or reset the controlsource to the desired worksheet.
..ControlSource="sheet2!a3"

Is that what you mean ?

NickHK

"Corey" wrote in message
...
Sorry Nick i do not understand what you mean ???

If i enter values intot he userform2 the values do not correspond to the
sheet i run the userform from they always refer to the values on the same
sheet.

Corey....
"NickHK" wrote in message
...
The unqualified range would assume the ActiveSheet.
Put a command button on a WS and add this code. select different
worksheets
and see that the range is updated, whichever sheet is active.

<WS code
Private Sub CommandButton1_Click()
UserForm1.Show vbModeless
End Sub
</WS code

<userform code
Private Sub UserForm_Click()
Range("A1").Value = "Value Added"
End Sub
</userform code

NickHK

"Corey" wrote in message
...
The below is the code that i am using to display and update values in

cells:
X3 & X6 on a sheet.
I have the rows and columns hiden from view, but the user can see the
current and modify if need by by using the userform.
However rather than creating a userform for each person, how can i use
the

1
userform to look at the SAME cells (X3 & X6) DEPENDING on what sheet

the
userform was run from????

I though the simple:
ACTIVESHEET.SELECT would do it but it seems to only look to the same

sheet.






Private Sub CommandButton1_Click()
activessheet.select
If Me.TextBox2.Value < "" Then
Range("X3").Value = Me.TextBox2.Value
End If
If Me.TextBox4.Value < "" Then
Range("X6").Value = Me.TextBox4.Value
End If
UserForm2.Hide
MsgBox "The amounts have been Renewed.", , "title...."
End Sub

Private Sub CommandButton2_Click()
UserForm2.Hide
End Sub

Private Sub Frame1_Click()

End Sub

Private Sub TextBox1_Change()
With Me.TextBox1
End With
End Sub

Private Sub TextBox2_Change()
End Sub

Private Sub TextBox3_Change()
End Sub

Private Sub TextBox4_Change()
End Sub

Private Sub UserForm_Initialize()
ActiveSheet.Select
With Me.TextBox1
.ControlSource = "X3"
End With
With Me.TextBox3
.ControlSource = "X6"
End With

End Sub



Regards


Corey....








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
userform that add data in all w/sheets tkraju via OfficeKB.com Excel Discussion (Misc queries) 0 March 24th 06 04:29 AM
Userform to enter values and shown in same userform in list helmekki[_104_] Excel Programming 0 November 19th 05 03:23 PM
Looping procedure calls userform; how to exit loop (via userform button)? KR Excel Programming 6 July 27th 05 12:57 PM
Activating userform and filling it with data form row where userform is activate Marthijn Beusekom via OfficeKB.com[_2_] Excel Programming 3 May 6th 05 05:44 PM
Access from add_in userform to main template userform.... Ajit Excel Programming 1 November 18th 04 05:15 PM


All times are GMT +1. The time now is 10:07 AM.

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

About Us

"It's about Microsoft Excel"