+ Reply to Thread
Results 1 to 9 of 9

Add formula next to every adjacent cell (except blanks)

  1. #1
    Registered User
    Join Date
    06-25-2017
    Location
    Australia
    MS-Off Ver
    365
    Posts
    76

    Question Add formula next to every adjacent cell (except blanks)

    Doing this manually, I paste a Table-referencing formula into an empty cell next to a cell of data, then I double-click that little square box in the bottom corner to auto-fill all the way down.

    Problem is, there is the occasional blank, so I just skip down and paste the formula again, auto-fill, and repeat until the formula is next to all cells in the A1 column.

    I've tried using Record Macro to automate this, unfortunately it can't record "autofill next to ALL cells in the column", only to end at a specific point. ie. B1:B300

    I've actually found several google results asking a VBA question similar to this, but they're all how to autofill only down to the last row (with no skips), while I need the formula pasted into ALL cells in column B (but only if there's data in column A)

    I hope I'm explaining right. The result should be like this:

    Data =IFERROR(INDEX(Table1...
    Data =IFERROR(INDEX(Table1...
    Data =IFERROR(INDEX(Table1...
    ‎  ‎ 
    Data =IFERROR(INDEX(Table1...
    Data =IFERROR(INDEX(Table1...
    ‎  ‎ 
    Data =IFERROR(INDEX(Table1...

    The VBA macro is basically:

    1. Select cell B1
    2. Paste [Formula]
    3. Paste same [formula] next to any cell in column A that has data.
    Last edited by 2vbr; 09-28-2020 at 11:30 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: Add formula next to every adjacent cell (except blanks)

    Why do you have occasional blanks? Sounds like mixing data with presentation.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    06-25-2017
    Location
    Australia
    MS-Off Ver
    365
    Posts
    76

    Re: Add formula next to every adjacent cell (except blanks)

    I don't make the workplace rules.

    I just have to deal with what I'm given, and leave the blanks untouched.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: Add formula next to every adjacent cell (except blanks)

    Post a sample workbook.

  5. #5
    Registered User
    Join Date
    06-25-2017
    Location
    Australia
    MS-Off Ver
    365
    Posts
    76

    Re: Add formula next to every adjacent cell (except blanks)

    Here we go.

    https://filebin.net/iyxa8gfcoiw2h2re

    (Spreadsheets are usually muuuuch bigger, with more data... but you get the idea. Again, I'm not allowed to shuffle data around for better presentation. I only have to add the formula to the right of the data.

    I actually have to do the same with other columns, but if I can get one simple VBA macro to do it once, I can just change column "A" and "B" to whatever I need.


    ...


    Um... I can't seem to get the Attachment option working.


    JBClR7g.png

    Is something supposed to happen when I click the "Attachments" button? Tried in both Firefox and Chrome.

    Anyway, I uploaded the sample elsewhere (link at top).



    EDIT: Okay, got the site-hosted links working via Manage Attachments. Took a few edits.
    Attached Files Attached Files
    Last edited by 2vbr; 09-28-2020 at 08:22 PM.

  6. #6
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,416

    Re: Add formula next to every adjacent cell (except blanks)

    Give this macro a try...
    Please Login or Register  to view this content.
    EDIT NOTE: This question has been multi-posted over in the MrExcel forum.
    Last edited by Rick Rothstein; 09-28-2020 at 09:35 PM.

  7. #7
    Registered User
    Join Date
    06-25-2017
    Location
    Australia
    MS-Off Ver
    365
    Posts
    76

    Re: Add formula next to every adjacent cell (except blanks)

    It works! Much appreciated!


    Quote Originally Posted by Rick Rothstein View Post
    This question has been multi-posted
    Is that a bad thing?

    I haven't been here that long, and I'm afraid I haven't yet picked up on any rivalries, or unspoken community faux pas.

  8. #8
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,416

    Re: Add formula next to every adjacent cell (except blanks)

    It is not a "rivalry" thing... it is a fairness thing. Think about it from the perspective of the people you asked to help you. You post on two (or more) different forums but do not tell either that you did that. On one site, you get a solution. On the other site, someone later comes along and works on the problem eventually coming up with a solution and posts it. That person doesn't know he/she just wasted valuable time they could have spent answering someone else's question because they spent it answering your question which you no longer care about because you got a solution (maybe days ago) on the other site. What you are supposed to do is mention on each forum you post at that you posted elsewhere and provide a link to that (those) other site(s). That way, people can check the other forum(s) first to see if you already got an answer or not before they attempt to answer your question. By the way, there is also an advantage to you to do this as well. You may get an answer at one of the sites, but it may be highly inefficient or have an undisclosed flaw in it... someone from another forum checking to see if you got an answer would see you did and could provide a better solution or point out potential flaws. If you don't give them links to each site you post at, they won't know to do that.

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: Add formula next to every adjacent cell (except blanks)

    I haven't been here that long, and I'm afraid I haven't yet picked up on any rivalries, or unspoken community faux pas.
    Three years is a while, albeit you haven't made many posts. All forums have the same rules about cross posting and wasting people's time, no matter what the topic ... and it WILL be noticed.

    The Attachment icon hasn’t worked for as long as I can remember. But see the yellow banner at the top of the page.

+ 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. Replies: 3
    Last Post: 07-21-2015, 05:10 PM
  2. [SOLVED] Move cells adjacent to each other (delete blanks)
    By bbarth in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-10-2015, 11:18 AM
  3. [SOLVED] Counting blanks in non-adjacent cells
    By ClickingNoise in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-20-2013, 08:46 AM
  4. [SOLVED] Add formula if adjacent cell has name in it but remove formula in adjacent cell is blank
    By How How in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2013, 10:42 AM
  5. Replies: 1
    Last Post: 02-18-2013, 01:46 AM
  6. [SOLVED] Need Help !!! How to multiply 2 adjacent columns with blanks
    By chico.corrales in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-07-2012, 01:15 PM
  7. Removing cells based on adjacent blanks
    By F6Hawk in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-28-2007, 08:17 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