LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default ask user to select a target sheet as an input for a macro

1) You would use this formula...

ActiveCell.FormulaR1C1 = "=VLOOKUP(R[1]C," & Answer &
"!R2C1:R255C3,3,FALSE)"

2) If you had them click on the sheet tab, then that sheet would be selected
and you would have the situation I mentioned in my previous reply, only
delayed slightly... ActiveSheet would tell you what sheet they were on. Here
is another thought... if you know they will have to change sheets to make
your macro work (that is, the look up data is never going to be on the page
they are on when the macro is launched, then perhaps you could make use of
the Workbook's SheetActivate event to get recognize the new sheet had been
selected and get the sheet name from its Sh argument?

Rick


"Yossi evenzur" wrote in message
...
Hi Rick
Please take a look at the following:
1)
Answer = InputBox("Tell me a sheet name")

'the Answer is"XXXX"

ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[1]C,'"What do I put HERE ???"'!R2C1:R255C3,3,FALSE)"

2) why can't i simply (simply?) click on the sheet?

"Rick Rothstein (MVP - VB)" wrote:

Another possibility... Execute this statement in your macro at the point
you
want to get the sheet name...

Answer = InputBox("Tell me a sheet name")

and then reference that sheet in your code using this Worksheets(Answer).
As
an example...

Worksheets(Answer).Range("D4").Value = "Hello"

You will probably need to put some error checking code in just in case
your
user types the sheet name in wrong though.

Rick


"Yossi evenzur" wrote in message
...
How or what is the vba syntax if i want the user to select a atrget
sheet for a macro as an input?




 
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
Input box to allow user to select column Marcusdmc Excel Programming 2 September 26th 07 08:08 PM
Macro with input box to Select a column on active sheet Marcusdmc Excel Programming 6 September 25th 07 07:53 PM
Input Box that allows user to select range joecrabtree Excel Programming 5 December 8th 06 04:48 PM
Help with Macro. -- User input for sheet name Michael A Excel Programming 9 January 6th 06 03:17 PM
CODE to select range based on User Input or Value of Input Field Sandi Gauthier Excel Programming 4 December 8th 03 03:22 PM


All times are GMT +1. The time now is 12:13 AM.

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

About Us

"It's about Microsoft Excel"