+ Reply to Thread
Results 1 to 9 of 9

Find a Variable's(cells) address

  1. #1
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Find a Variable's(cells) address

    I have been using this code to find a variables address, but is there something more efficient?

    In the below code I am trying to find the variable "celval" which can reside anywhere in a range
    I first find "celval" with find to get the strings value then use the second line to get the column or row number.

    Please Login or Register  to view this content.
    Cheers
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Find a Variable's(cells) address

    You can use just one line
    Please Login or Register  to view this content.
    or change column for Row

    Or you can find it's address:
    Please Login or Register  to view this content.
    or find the address like this
    Please Login or Register  to view this content.
    Google Me
    Find me located here Simon Lloyd
    and what i'm about Here
    The above is NOT a link to a forum so is NOT against Rule 13
    Last edited by Simon Lloyd; 02-12-2012 at 03:30 AM.

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Find a Variable's(cells) address

    Hi JapanDave,

    I have tried the above Codes from Simon Lloyd, and it either does nothing, or one gave me some Error Message.

    I have put this together, tested it and works like a charm!

    Please Login or Register  to view this content.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Find a Variable's(cells) address

    Sorry, my explanation was bad.

    My code works no problem. I was trying to find a more efficient way of writting.

    Simon, I have tried this before and I can't get the column or row number.
    Please Login or Register  to view this content.
    This line gives you the found cell's column number no problem.

    Please Login or Register  to view this content.
    That is not the problem, the lenght of the code is.



    @Winon,
    all that your code is doing is activating the found cell. I want the row or col number. As I said before , my code works , I just want a better way to do it, if there is one?

    Please Login or Register  to view this content.
    Last edited by JapanDave; 02-12-2012 at 05:42 AM.

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Find a Variable's(cells) address

    @Simon Lloyd,

    Sorry Simon, I can't get your code to work on Excel2007. The code I offered JapanDave, also only works if the word "Apple" appears somewhere within the given Range?

  6. #6
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Find a Variable's(cells) address

    Hi JapanDave,

    I can't get your code to work either. Paste this line at the Bottom of your Code.

    Please Login or Register  to view this content.
    Would you then please be so kind as to Post me your Complete Working Code for Excel 2007?

    Thank You

  7. #7
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Find a Variable's(cells) address

    I ran this with no issues at all????
    Please Login or Register  to view this content.

    Google Me
    Find me located here Simon Lloyd
    and what i'm about Here
    The above is NOT a link to a forum so is NOT against Rule 13

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Find a Variable's(cells) address

    Either:
    c01 resulting in a range, because of using 'Set'
    Please Login or Register  to view this content.
    or
    c01 resulting in a string:
    Please Login or Register  to view this content.



  9. #9
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Find a Variable's(cells) address

    Here You go have a play with this, just copy all the code over to a new mondule and run .. see what happens

    The code open so easy to edit, any problems post back. Your code does not give the address as stated only the row unless Jacks missing soemthing

    jiuk
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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