ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Assign macro (https://www.excelbanter.com/excel-programming/340050-assign-macro.html)

jenniferThomson

Assign macro
 

Hi

I am having a few problems creating a userform and a command button o
my worksheet to activate my userform. I am using excel 2003. I hav
situated the command button on the worksheet but how do I get this t
open my userform.

On the userform form I have a button which when pressed should ente
the details onto the form but it does not work. Here is my code fo
the button

private sub cmdOK_Click()

ActiveWorkbook.sheets("Tender Information"). activate

I thought this line would activate the sheet

and then I added
Range ("G2").select

End sub

this is where is want my first entry from my userform to go.

I am a novice to these features of excel and I would be very gratefu
to any replies with assistance.

Jennifer Thomso

--
jenniferThomso
-----------------------------------------------------------------------
jenniferThomson's Profile: http://www.excelforum.com/member.php...nfo&userid=456
View this thread: http://www.excelforum.com/showthread.php?threadid=46750


dominicb[_123_]

Assign macro
 

Good afternoon Jennifer Thomson

To show your userform use this line in your command button code:

UserForm1.Show

assuming it's called UserForm1, of course (Tender Information isn't
valid name).

These commands will close your userform (there is a subtle differenc
between the two commands)

UserForm1.Hide

or

Unload UserForm1

In terms of where your first entry will be, this is determined in th
objects property in the userform. Open a userform, click on any objec
and then look in the properties window for the TabIndex property. Th
objects will be cycled through in the order of their TabIndex propert
values.

HTH

Dominic

--
dominic
-----------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...fo&userid=1893
View this thread: http://www.excelforum.com/showthread.php?threadid=46750


JNW

Assign macro
 
To activate the userform place the following in the code for the button on
the worksheet
userform.show

If you are entering information on the user form, change the ControlSource
property to reference the cell you want changed. i.e. if you have
textbox1 that contains information to move to sheet "Tender Information" cell
G2 then put the following in the ControlSource property for textbox1. (don't
forget the apostrophes)
'Tender Information'!G2

after doing this for all of your inputs on the user form then you can use
the button on the form to close the form.
unload userform


JNW

"jenniferThomson" wrote:


Hi

I am having a few problems creating a userform and a command button on
my worksheet to activate my userform. I am using excel 2003. I have
situated the command button on the worksheet but how do I get this to
open my userform.

On the userform form I have a button which when pressed should enter
the details onto the form but it does not work. Here is my code for
the button

private sub cmdOK_Click()

ActiveWorkbook.sheets("Tender Information"). activate

I thought this line would activate the sheet

and then I added
Range ("G2").select

End sub

this is where is want my first entry from my userform to go.

I am a novice to these features of excel and I would be very grateful
to any replies with assistance.

Jennifer Thomson


--
jenniferThomson
------------------------------------------------------------------------
jenniferThomson's Profile: http://www.excelforum.com/member.php...fo&userid=4561
View this thread: http://www.excelforum.com/showthread...hreadid=467508



jenniferThomson[_2_]

Assign macro
 

Thank for your replies both have helped me understand what I am trying
to achieve and then some.

I am very grateful.

Jen


--
jenniferThomson
------------------------------------------------------------------------
jenniferThomson's Profile: http://www.excelforum.com/member.php...fo&userid=4561
View this thread: http://www.excelforum.com/showthread...hreadid=467508


jenniferThomson[_3_]

Assign macro
 

Hi

I appreciate the help already given but I need some more help with my
userform. So here goes:

File named Tender Information data entry, 4 worksheets, one named
Tender information is the sheet that the userform is attached. Button
called enter name


Private Sub cmdentername_Click()

frmTenderEnq.Show

End Sub


This enables me to press enter name and userform comes up.

I have the form codes

Private Sub UserForm_Initialize()

With cboerby
..AddItem "JM"
..AddItem "PC"
..AddItem "JT"

End With

cboerby.Value = ""

End Sub

and an okay button on form

Private Sub cmdok_Click()




End Sub

This is were I need help I want the answer to go into cell G2 after
this button has been clicked but at the moment when I use the form
nothing happens.

What should I enter under Private Sub cmdok_Click() and before End Sub
to make this happen.

Any assistance would be greatly appreciated

Jennifer


--
jenniferThomson
------------------------------------------------------------------------
jenniferThomson's Profile: http://www.excelforum.com/member.php...fo&userid=4561
View this thread: http://www.excelforum.com/showthread...hreadid=467508


Dave Peterson

Assign macro
 
I like to qualify my objects. Me.cboerby means that it's the cboerby that's
part of this userform.

Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
With Me.cboerby
.AddItem "JM"
.AddItem "PC"
.AddItem "JT"
End With
End Sub
Private Sub cmdok_Click()

If Me.cboerby.ListIndex < 0 Then
'do nothing, nothing selected
Else
Worksheets("sheet1").Range("G2") = Me.cboerby.Value
Unload Me '???
End If

End Sub

I plopped it into Worksheets("Sheet1"), too.

jenniferThomson wrote:

Hi

I appreciate the help already given but I need some more help with my
userform. So here goes:

File named Tender Information data entry, 4 worksheets, one named
Tender information is the sheet that the userform is attached. Button
called enter name

Private Sub cmdentername_Click()

frmTenderEnq.Show

End Sub

This enables me to press enter name and userform comes up.

I have the form codes

Private Sub UserForm_Initialize()

With cboerby
AddItem "JM"
AddItem "PC"
AddItem "JT"

End With

cboerby.Value = ""

End Sub

and an okay button on form

Private Sub cmdok_Click()

End Sub

This is were I need help I want the answer to go into cell G2 after
this button has been clicked but at the moment when I use the form
nothing happens.

What should I enter under Private Sub cmdok_Click() and before End Sub
to make this happen.

Any assistance would be greatly appreciated

Jennifer

--
jenniferThomson
------------------------------------------------------------------------
jenniferThomson's Profile: http://www.excelforum.com/member.php...fo&userid=4561
View this thread: http://www.excelforum.com/showthread...hreadid=467508


--

Dave Peterson


All times are GMT +1. The time now is 10:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com