Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Get current cell after OK on user form?

I made a user form that opens when you double-click in certain cells. On
the form, you write some values, and then click OK. In the code for the
OK button, how do you know what cell the user double-clicked on?

Gustaf
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Get current cell after OK on user form?

Hi Gustaf

This line needs to go before your code select other cells.

TargetCell= activecell.address

Regards,
Per

"Gustaf" skrev i meddelelsen
...
I made a user form that opens when you double-click in certain cells. On
the form, you write some values, and then click OK. In the code for the OK
button, how do you know what cell the user double-clicked on?

Gustaf


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Get current cell after OK on user form?

Copy the worksheet code into a sheet module and add a userform with a button
for the form code. Double-click a cell within A1:B10.

' Worksheet code

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Range, Cancel As Boolean)

If Intersect(Range("A1:B10"), Target) Is Nothing Then Exit Sub
Cancel = True
Set UserForm1.mCellClicked = Target
UserForm1.Show

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

'' end worksheet module

'' userform code

Public mCellClicked As Range

Private Sub CommandButton1_Click() ' the OK button

MsgBox mCellClicked.Address & vbCr & _
mCellClicked.Parent.Name
End Sub

I suspect the above will be enough for your needs but you might also look
into Property Set/Let and Get pairs (Set for objects or Let for variables).

Regards,
Peter T


"Gustaf" wrote in message
...
I made a user form that opens when you double-click in certain cells. On
the form, you write some values, and then click OK. In the code for the
OK button, how do you know what cell the user double-clicked on?

Gustaf



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
inserting current windows user id into a cell MartyMack74 Excel Worksheet Functions 2 November 14th 09 12:14 AM
How do I fill a cell in a user form from a selection on same form? Terry Tipsy Excel Discussion (Misc queries) 4 June 11th 07 02:59 PM
Data from user form to certain cell parteegolfer Excel Programming 4 March 22nd 06 05:13 PM
Determine the current cell while inside a User Defined Function pmax Excel Programming 2 February 1st 06 11:47 PM
current cell in user-defined function Julio Kuplinsky Excel Programming 3 December 8th 03 06:24 PM


All times are GMT +1. The time now is 06:36 PM.

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"