+ Reply to Thread
Results 1 to 8 of 8

Introduce a formula next to Active Cell

  1. #1
    Registered User
    Join Date
    04-20-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    96

    Introduce a formula next to Active Cell

    Hi,

    I'm working on a macro but got stock with this. I need the code to add a column to the right of the active cell (which I achieved), then I need to add a formula on the cell to the right of the Active Cell, and below, for as many rows as column A has content (this is the part I need help with.

    My current (broken) code is as follows:


    Please Login or Register  to view this content.
    What do I have to change to achieve this?

    Thanks for your help

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Introduce a formula next to Active Cell

    Perhaps...
    Please Login or Register  to view this content.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    04-20-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: Introduce a formula next to Active Cell

    Hi Sintek!,

    Thank you so much for your help! I tried the code, and it works! ... only issue is it goes ahead and adds the formula one extra row at the end. So, if column A has content down to row 15, the code adds the formula to row 16 too (B16). How can this be avoided?

    Thanks!

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Introduce a formula next to Active Cell

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-20-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: Introduce a formula next to Active Cell

    Hi Sintek!

    Well, I tried the code, and it both worked and not. Let me explain. Adding that "-1" took care of the extra row having the formula. But, the problem I have now, is that it won't work if the active cell is located at a different row, other than row 2. If the active cell is A5, and I have content from A1 through A10, it will add the formula starting in cell B5, and will add it for as many rows as the ones having content in column A. I do understand that is more related with the first part of the code, asking to count rows in column A. Any idea about how can I avoid that? What I need is that the code counts the rows starting with the Active cell down.

    Thanks!

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Introduce a formula next to Active Cell

    Not quite sure I understand...This will add the date in Col B the number of entries from Active cell to last row in active cell Column
    Try this...
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-20-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    96

    Re: Introduce a formula next to Active Cell

    Hi Sintek,

    Sorry for delayed response. Got stuck with work this week. First of all, I appreciate you took the time to look into this issue again. I tried the code and it worked, but has a flaw. To better illustrate what I'm trying to do, I'm attaching a sample workbook where I used your code having some sample data in column A & B. The active cell was A5. As you can see, a new column was inserted then the formula added. The only problem is that the last row containing data in column A didn't get the formula in column B. As a reference, I'm adding the same 2 columns to the right of those, where the added date goes all the way down to the last used row in the first column.
    Attached Files Attached Files

  8. #8
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Introduce a formula next to Active Cell

    Is this what you are after...
    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)

Similar Threads

  1. [SOLVED] If active cell value dosn't match in range then highlight the active cell
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-18-2017, 12:38 AM
  2. Changing a cell reference in formula based on its position and not the active cell
    By Glovaldo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-09-2017, 07:10 AM
  3. Pasting a formula between two active cells - one active cell varies
    By Andrewstupendo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-21-2015, 01:23 PM
  4. Replies: 6
    Last Post: 03-03-2014, 02:28 PM
  5. Problems with autofilling formula down the active column to the end row using active cell
    By sl_riches2179 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-27-2013, 09:30 AM
  6. Replies: 2
    Last Post: 12-23-2012, 09:26 AM
  7. Formula tags introduce spaces in formulas
    By npamcpp in forum Suggestions for Improvement
    Replies: 15
    Last Post: 08-16-2012, 08:18 AM

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