+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    03-13-2010
    Location
    Bedfordshire, England
    MS-Off Ver
    Excel 2003
    Posts
    49

    Copy cell, if cell blank move to cell?

    I am having trouble writing a code to copy a number from one cell into another cell. Basically if the cell is blank I want to move horizontally to the cell to the left and copy that one, if thats blank move to the left again until a number is found.

    My data cells B109 to H109. I thought something like this would work =IF(H109="",IF(G109="",F109)) but this is as far as I can get it to work, if I use this =IF(H109="",IF(G109="",IF( F109="",E109))) it returns false. I'm sure there must be a simpler way of achieving this.

    Thanks in advance
    Last edited by BobTheRocker; 03-14-2010 at 08:07 AM.

  2. #2
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,477

    Re: Copy cell, if cell blank move to cell?

    right or left?
    find the first number after blanks

    =index(b109:h109,match(true,index(b109:h109>0,0),0))

    eg in blank,blank 1,2,3,5,5 it will return 1
    or
    find the last number used is
    =LOOKUP(10^99,B109:H109)
    1,2,3,4,5,blank ,blank will return 5
    Last edited by martindwilson; 03-14-2010 at 06:54 AM.
    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    02-15-2008
    Location
    Grappenhall, UK
    MS-Off Ver
    Excel for Windows & Mac - all versions.
    Posts
    5,826

    Re: Copy cell, if cell blank move to cell?

    Hi Bob, and welcome to the forum.

    One way

    Code:
    =INDEX(B109:H109,1,MATCH(9E+307,B109:H109))
    HTH
    Richard Buttrey

    If this was useful then please rate it appropriately.

    Click the small star icon at the bottom left of my post.

  4. #4
    Registered User
    Join Date
    03-13-2010
    Location
    Bedfordshire, England
    MS-Off Ver
    Excel 2003
    Posts
    49

    Re: Copy cell, if cell blank move to cell?

    Brilliant guys, thanks very much. Both your methods work. Out of interest Martin, what does the 10^99 signify. Equally Richard what does the 9E+307 signify. New to excel, just trying to understand its scripting better.

  5. #5
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,477

    Re: Copy cell, if cell blank move to cell?

    10^99 is just a big number the biggest being what richard used 9E+307
    i just can never remember it lol. as long as its bigger than any number in your range it matches the last one in lookup
    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

Thread Information

Users Browsing this Thread

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

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.2.0