+ Reply to Thread
Results 1 to 17 of 17

How to fill in a cell based on the last bold cell of another column?

  1. #1
    Registered User
    Join Date
    04-01-2020
    Location
    Brussels
    MS-Off Ver
    Office365
    Posts
    8

    Lightbulb How to fill in a cell based on the last bold cell of another column?

    Hi all,

    I would like to write a code that would fill in cells in column A by the last bold cell/or numerical cell (both would work) that is in column B (if we are in cell A10, the VBA code should only look at values between B1 and B10, and take the last numberical or bold cell from that range).

    I attached a quick example of what I would like to do with the code

    Many thanks for the help!

    Alen
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to fill in a cell based on the last bold cell of another column?

    What do you mean by
    if we are in cell A10
    and
    and take the last numberical or bold cell from that range
    what do you want to do after the "take"?

  3. #3
    Registered User
    Join Date
    04-01-2020
    Location
    Brussels
    MS-Off Ver
    Office365
    Posts
    8

    Re: How to fill in a cell based on the last bold cell of another column?

    Hi Jindon,

    I have a sheet of 9k rows. Therefore, what I would like to do is to populate all the cells from A1 to A9000.
    The way we fill the cells from A1 to A9000 will depend on what is in column B.

    An example:

    We are at the 20th row, what needs to be filled in A20 is based on what is filled in the range of B1-B20. If B20 is not a number (or a cell that contains a bolded content), it should take a look at B19, B18, B17, until it finds a numerical cell (or bolded cell). Then, when it found it, the code should fill in A20 with that value.

    I hope that this is a bit better now?

    Many thanks for your time Jindon, highly appreciated!

    Alen

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to fill in a cell based on the last bold cell of another column?

    So, Activecell...
    See if this is how you wanted.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-01-2020
    Location
    Brussels
    MS-Off Ver
    Office365
    Posts
    8

    Re: How to fill in a cell based on the last bold cell of another column?

    Hi Jindon,

    Thanks for the reply. The code you provided seems to work only when the activated cell is on the same row that the bolded cell in column B.
    Would you know how to fix that?

    Thanks!

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to fill in a cell based on the last bold cell of another column?

    The code will copy the last Numeric value in Col.B to Col.A.

    If activecell is A22, it copies B16 to A16, the last numeric value within B1:B22, that was how I read your problem.

  7. #7
    Registered User
    Join Date
    04-01-2020
    Location
    Brussels
    MS-Off Ver
    Office365
    Posts
    8

    Re: How to fill in a cell based on the last bold cell of another column?

    Hi Jindon,

    If activecell is A22, it should copy B16 (the last numeric value) to A22 ... Is this possible to do? And of course repeat that process for the 9k rows.

    Again, many thanks!

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to fill in a cell based on the last bold cell of another column?

    Then change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-01-2020
    Location
    Brussels
    MS-Off Ver
    Office365
    Posts
    8

    Re: How to fill in a cell based on the last bold cell of another column?

    Great, this works perfectly!
    What should I add to the code in that way, it runs from A1 to A9000?

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to fill in a cell based on the last bold cell of another column?

    I don't understand what you are trying to say.

    A1:A9000 instead of Col.B? or you just want to restrict the code to run only when active cell is in somewhere in A1:A9000?

  11. #11
    Registered User
    Join Date
    04-01-2020
    Location
    Brussels
    MS-Off Ver
    Office365
    Posts
    8

    Re: How to fill in a cell based on the last bold cell of another column?

    I have to apply that code that you created to all the cells in column A (until the 9000th row):

    For A1: run the code in order to have the last numerical cell in column B (in this case it's B1 since B1 contains a number)
    For A2: run the code in order to have the last numerical cell in column B (B1 will be shown in A2 since B2 does not contain a numerical cell)
    ...
    Until A9000

    If you do not understand what I mean, you could check the Excel I uploaded in the beginning, this will definitely help you see what I mean ..

    Thanks!!

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to fill in a cell based on the last bold cell of another column?

    Not clear though.
    It will not run when ActiveCell is not in A1:A9000.
    Please Login or Register  to view this content.

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to fill in a cell based on the last bold cell of another column?

    Ahh, is this what you wanted?
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    04-01-2020
    Location
    Brussels
    MS-Off Ver
    Office365
    Posts
    8

    Re: How to fill in a cell based on the last bold cell of another column?

    Hi Jindon,

    Thanks for giving me a lot of your time (this code works the same as the previous one). Maybe I was not that clear ...
    I just wanted the code to repeat itself (the same code to loop from A1 to A9000). Now when I run the code I have the correct answer but just for the cell that was active, while I would like to have the results for all the cells in column A ...

    I guess a loop function has to be inserted somewhere in the code right?

    Thanks!

  15. #15
    Registered User
    Join Date
    04-01-2020
    Location
    Brussels
    MS-Off Ver
    Office365
    Posts
    8

    Re: How to fill in a cell based on the last bold cell of another column?

    Yessss thanks!!! It works perfectly now! Great, many thanks for your time! will take time to understand the code!

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to fill in a cell based on the last bold cell of another column?

    OK, took time to understand what you are trying to do.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,752

    Re: How to fill in a cell based on the last bold cell of another column?

    Administrative Note:

    Welcome to the forum.

    FOR FUTURE REFERENCE

    We would very much like to help you with your query, however the thread title does not really convey what your request is about.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. As you are new here, I will provide the link for you.)

    https://www.mrexcel.com/board/thread...-cell.1129317/
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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. Auto fill column based on sum value in top most cell
    By dipnfalls in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-16-2020, 05:08 AM
  2. Replies: 8
    Last Post: 03-28-2018, 04:12 AM
  3. sort all white fill cell on column I based on cell value specific txt if (true)
    By raijinlee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-01-2017, 01:57 AM
  4. [SOLVED] VBA code to fill a cell in a column based on another column
    By donhadriano in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-10-2015, 07:51 AM
  5. Replies: 7
    Last Post: 12-05-2013, 04:06 PM
  6. [SOLVED] Fill a cell in Column B based on the text in Column A using a table on sheet 2
    By lbrasfie in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-25-2013, 01:56 PM
  7. Fill Row Header based on cell in column
    By diggerd in forum Excel General
    Replies: 2
    Last Post: 01-06-2010, 09:59 PM

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.6.0 RC 1