+ Reply to Thread
Results 1 to 3 of 3

Getting Range from Application.InputBox returns range from different worksheet - addin

  1. #1
    Registered User
    Join Date
    07-19-2019
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    1

    Getting Range from Application.InputBox returns range from different worksheet - addin

    I created a macro that take a table of data, where different values of inputs are column headers, and converts it to a list. The macro uses the function 'Application.InputBox(,,,,,,,8)' to get the range of the table to translate into a list. The macro worked fine when executed form the same workbook that had the table. I like this macro so much that I included it in an Addin for myself, but often when I execute this function from the Addin, the range that gets returned for the table is not from the same worksheet the the macro was executed form.

    The code that gets the range is shown below:
    Please Login or Register  to view this content.
    Again, this is executed from an addin. When stepping through this code using breakpoint and "Watch" item, I see that ActiveSheet.Name is set to the sheet that I was on when I executed this function, but xRg.Worksheet.Name is not the same as the ActiveSheet.Name. I have several other worksheets open at the same time.

    This function works fine when I only have one workbook open, but I would like it to work always so I don't need to close workbooks in order to use this.

    Does anyone know what is going on or how to fix this?

    Thanks
    Last edited by davesexcel; 12-20-2019 at 04:39 PM.

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Getting Range from Application.InputBox returns range from different worksheet - addin

    the range that gets returned for the table is not from the same worksheet the the macro was executed form.
    You mean xRg in your macro ??
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Getting Range from Application.InputBox returns range from different worksheet - addin

    xRg.Worksheet.Name is not the same as the ActiveSheet.Name.
    No of course if the selection has been done in another file, in another sheet

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Export Range to PDF with Application for Range and SaveAs
    By tmalito in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-05-2014, 02:28 PM
  2. Getting the worksheet from which a range was set using the inputbox
    By SidewinderAM9M in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-16-2013, 10:55 PM
  3. [SOLVED] Why doesn't Application.Index write array column to worksheet range?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2013, 02:07 AM
  4. Screen positioning inputbox that is set as Application.InputBox
    By vdongen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-06-2010, 07:59 AM
  5. formula which returns horizantal range to vertical range
    By unas in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 04-29-2010, 09:58 AM
  6. RefEdit returns range address - not range value!!!
    By pmguerra in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-04-2007, 07:33 AM
  7. [SOLVED] Addin out of range error
    By Trux in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-19-2005, 10:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1