Pass a variable to a userform

Andy Gee

New Member
Joined
Feb 26, 2002
Messages
48
Hi, I'm new to userforms hence all the questions! I have a userform which pops up when a cell is selected, it then enters the data into the cell selected. I thought I could just copy the userform and modify slightly for the other 200 cells in the column. Doh!

I think a better solution would be to use just one form and pass a variable to it, letting it know which cell to enter the details into.
The code I have for activating the userform is this...

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Address = "$E$4" Then Ex1.Show
End Sub

Thanks Audiojoe!
But I need to send that cell to the userform.

Any ideas? Thanks in advance for any help.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
What do you mean when you say that you need to send that cell to the userform? Do you mean that it's value appears on there somewhere?
 
Upvote 0
No, I would like it to remember what cell was clicked, store it in a variable, and use that variable to enter the form details back into the clicked cell.
This message was edited by Andy Gee on 2002-04-11 08:56
 
Upvote 0
Maybe if I could just store the Target.Address in a variable then use it when the command button is pressed I could get it to work.

I tried this with
cellName = (Target.Address)
When clicking the cell

and
Range(cellName).Value = Textbox1.Value
when the command button is pressed.
But I get an error message...
Method 'Range' of object '_Global' failed

Please help!
 
Upvote 0
juts wondering how can u have spinner in the user form? it doesn't work for me, so i am wondering what have i done wrong?

i set the cell link to of the spinner to a offset refernce, can any1 please help me on this?

:)
 
Upvote 0
I don't have a spinner! I need to be able to store a variable in one macro and use it in another.
Give me some more info on what you need and I'll try to help!
This message was edited by Andy Gee on 2002-04-11 09:21
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,433
Members
448,897
Latest member
ksjohnson1970

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top