Results 1 to 2 of 2
  1. #1
    5 Star Lounger jujuraf's Avatar
    Join Date
    Jun 2001
    Location
    San Jose, California, USA
    Posts
    1,061
    Thanks
    0
    Thanked 0 Times in 0 Posts

    fetching range from InputBox (xl2000, SP2)

    I have a form which has text fields and buttons that use Application.InputBox to retrieve the data from a user-selected cell (the Type field in InputBox = 8 for range). In my project I need to know both the address of the selected cell as well as its contents. When I use:

    <pre>Dim dat as Variant
    dat = Application.InputBox("Locate the cell that contains the LO value", _
    "LO Data", "NONE", Type:=8)
    </pre>

    This returns the contents of the cell but I also need to get its address (the user points at the cell and its value is returned to me). How can I do that? My project requires that I know the source of the data as well as its value so that I can later change it (via code).

    I tried setting the return of Application.InputBox to a range but that generated an error. I was hoping I could get the range and then I'd have both the cell's address as well as its contents available to me for further processing. Is there another way to obtain this information?

    Thnx, Deb <img src=/S/bash.gif border=0 alt=bash width=35 height=39>

  2. #2
    5 Star Lounger jujuraf's Avatar
    Join Date
    Jun 2001
    Location
    San Jose, California, USA
    Posts
    1,061
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: fetching range from InputBox (xl2000, SP2)

    PROBLEM SOLVED!. Jeessh, if I'd read the help for InputBox a bit closer....

    The answer is that I didn't properly use the range object to return the range, I had to use Set which I didn't. So I now can do this and get both the addess and the cell's contents <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>
    <pre>Dim rng as Range
    Set rng = Application.InputBox("Locate the cell that contains the variable's name", _
    "Variable Name", "NONE", Type:=8)
    </pre>


    Where rng.address gives me the address and rng gives me the cell's contents. Perfect!

    Deb <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

Posting Permissions

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