+ Reply to Thread
Results 1 to 15 of 15

replace cell with above value if not empty

  1. #1
    Forum Contributor
    Join Date
    04-25-2014
    Location
    India
    MS-Off Ver
    Excel pro plus 2021
    Posts
    186

    replace cell with above value if not empty

    hello friends ,
    i have series of numbers in column a
    i would like to replace "#value" with above value if not blank cell , with change in value of -4
    if above cell is empty then it takes below cell values and minus -4
    Last edited by raj soni; 12-12-2014 at 12:52 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: replace cell with above value if not empty

    Try this:

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    04-25-2014
    Location
    India
    MS-Off Ver
    Excel pro plus 2021
    Posts
    186

    Re: replace cell with above value if not empty

    hi alansidman,
    thanks for prompt reply ,

    but i am getting error on
    If IsError(Range("A" & i)) And Range("A" & i - 1) <> "" Then

    any idea why ?

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: replace cell with above value if not empty

    What is the error message? Does your data look exactly as you have shown in your example? The code worked for me based upon the example presented. If your data sheet is different then I suggest you post a copy of your data sheet (upload) so that the code can be tweaked. It is difficult for a doctor to diagnose a patients issues if he cannot examine the patient. Same theory applies here.

  5. #5
    Forum Contributor
    Join Date
    04-25-2014
    Location
    India
    MS-Off Ver
    Excel pro plus 2021
    Posts
    186

    Re: replace cell with above value if not empty

    i just took different values,

    #VALUE!
    #VALUE!
    #VALUE!
    #VALUE!
    #VALUE!
    -18
    Last edited by raj soni; 12-12-2014 at 12:52 AM.

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: replace cell with above value if not empty

    In your current example, you start with #value. Since there is no value directly above or beneath it, what should the new value be? This example does not fall into the criteria you asked for in your first post.

  7. #7
    Forum Contributor
    Join Date
    04-25-2014
    Location
    India
    MS-Off Ver
    Excel pro plus 2021
    Posts
    186

    Re: replace cell with above value if not empty

    Attachment 364028


    sorry alansidman , for inconvience ,

    i have attach sample file ...

    also ,

    if order is in

    -18
    #VALUE!
    #VALUE!
    #VALUE!
    #VALUE!
    #VALUE!

    its works perfectly

    but if order is in
    #VALUE!
    #VALUE!
    #VALUE!
    #VALUE!
    #VALUE!
    -18

    it doesnt replace with lower cell values ,
    can we do something about this too ?
    Last edited by raj soni; 12-12-2014 at 12:50 AM.

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: replace cell with above value if not empty

    In your original post you indicated that if after a break, then the macro should look to the next cell below and subtract 4. Your current scenario does not allow this as it is also and error record. What should your criteria be if this is the case? Obviously, you cannot subtract 4 from a #value. Please elaborate on your criteria.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: replace cell with above value if not empty

    Maybe ...

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  10. #10
    Forum Contributor
    Join Date
    04-25-2014
    Location
    India
    MS-Off Ver
    Excel pro plus 2021
    Posts
    186

    Re: replace cell with above value if not empty

    hi , alansidman

    if all values in group are as following as below , then marco moves to next group .

    #VALUE!
    #VALUE!
    #VALUE!
    #VALUE!
    #VALUE!
    #VALUE!

  11. #11
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: replace cell with above value if not empty

    See if this works for you:

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    04-25-2014
    Location
    India
    MS-Off Ver
    Excel pro plus 2021
    Posts
    186

    Re: replace cell with above value if not empty

    thanks alansidman, its working fine , but only one small fix needed ,
    Last edited by raj soni; 12-12-2014 at 12:51 AM.

  13. #13
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: replace cell with above value if not empty

    I'm out of ideas on how to make this work. Will seek additional help from others in the forum.

  14. #14
    Forum Contributor
    Join Date
    04-25-2014
    Location
    India
    MS-Off Ver
    Excel pro plus 2021
    Posts
    186

    Re: replace cell with above value if not empty

    ok sir , thanks for your efforts.

    but please go through one last time to file attach ,

    so you will idea of what i am trying to do ,

    its my mistake , i dint posted question properly for answer i expected.

    Attachment 364175
    Last edited by raj soni; 12-12-2014 at 12:48 AM.

  15. #15
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: replace cell with above value if not empty

    Hi,

    Try this code for your sample file at post #14 :

    Please Login or Register  to view this content.
    Regards
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

+ 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. Find a cell that has a null value, and replace with an empty string.
    By skania in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-20-2013, 12:49 PM
  2. [SOLVED] Extract date from cell and replace value with date then delete empty rows
    By jjislas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-03-2013, 11:52 AM
  3. How to replace an empty cell with the data of the one above
    By LennyP in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-19-2013, 03:41 AM
  4. replace empty cell
    By wkilc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-19-2010, 08:35 PM
  5. Find date and replace if another cell is empty
    By CJ944 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2010, 08:29 AM

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