referencing Sheet from UserForm code

J

Jock

User types an "X" in a cell in Sheet!1, column AH.
This triggers code which will open Userform11.
On this Userform are two command buttons.
When CommandButton1 is selected, I need my code to reference the cell in
column F on same row as the "X" was input but I don't know how to get it to
do this as the code is in the Userform.
Thanks,
 
D

Dave Peterson

You could declare a public variable in a General module (not in the userform,
not in the worksheet module).

Public MyRow as long

Then assign a value to that in your worksheet_change(???) event.
myrow = target.row

And use it in the code in your userform
msgbox activesheet.cells(myrow,"F").value
 
R

Rick Rothstein

If I understand your set up correctly, I think the cell reference you want
would be this...

Cells(ActiveCell.Row, "F")

So, if you had a Range variable that you wanted to set a reference back to
this cell...

Set MyRangeVariable = Cells(ActiveCell.Row, "F")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top