+ Reply to Thread
Results 1 to 13 of 13

If Then Macro for copying formulas please

  1. #1
    Forum Contributor
    Join Date
    01-28-2013
    Location
    Spencerport, NY
    MS-Off Ver
    Excel 2016
    Posts
    270

    If Then Macro for copying formulas please

    Hello All

    I did not have any luck by posing this question in the Formulas section of this forum, and it was suggested that the experts in the Macro world may be able to help. In the attached spreadsheet, you will notice different formulas in each cell from F5 to AK5. These are necessary due to the insurances I have to work with and how I need to report these out.

    The Macro I am hoping that can be developed is something that will help me do the following:

    I need the formulas from F5 through AK5 to be inserted in their corresponding columns when a Cell in Column A returns some sort of text. In other words, Cell A11 has text inserted( name ). I need my formulas from F5, G5, H5 etc to show up in every corresponding column (F11, G11, H11 etc, F16,G16,H16 and so on) that has text in Column A. Essentially this is what I did manually for a few rows in this abbreviated spreadsheet, but the spreadsheet I am working on has more then 60K rows.

    Thanks so much
    Ron
    Attached Files Attached Files

  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,885

    Re: If Then Macro for copying formulas please

    Put this in the Worksheet_Change Event for the sheet in question

    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
    01-28-2013
    Location
    Spencerport, NY
    MS-Off Ver
    Excel 2016
    Posts
    270

    Re: If Then Macro for copying formulas please

    Thank you very much Alan ! I am very grateful for your time. Now I just have to figure out what you mean by" Put this in the Worksheet_Change Event for the sheet in question" as I am very new to the Macro world

  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,885

    Re: If Then Macro for copying formulas please

    Open the VBE (Alt +F11). Double click on the sheet in the left window. A new VBA window will open. Copy the code I provided and paste into the new window.

  5. #5
    Forum Contributor
    Join Date
    01-28-2013
    Location
    Spencerport, NY
    MS-Off Ver
    Excel 2016
    Posts
    270

    Re: If Then Macro for copying formulas please

    Got it ! Thank you again Alan

  6. #6
    Forum Contributor
    Join Date
    01-28-2013
    Location
    Spencerport, NY
    MS-Off Ver
    Excel 2016
    Posts
    270

    Re: If Then Macro for copying formulas please

    Alan
    Sorry to bother you. Can you tell me why when I try to copy the real names into column A from the master I have, the rows do not update. Will your code not work if I copy and paste into column A?

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: If Then Macro for copying formulas please

    Ron, you should have stayed with your initial post, rather than post a duplicate thread

    I have tried to merge them, but am unable to at the moment
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: If Then Macro for copying formulas please

    Modified from the other thread:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  9. #9
    Forum Contributor
    Join Date
    01-28-2013
    Location
    Spencerport, NY
    MS-Off Ver
    Excel 2016
    Posts
    270

    Re: If Then Macro for copying formulas please

    Thank you very much XLADEPT
    I apologize, I know noting about Macros.This is what I have pasted but I am getting an error. "COMPILE ERROR VARIABLE not defined" ( The r is highlighted in the code) Can you tell me what I did wrong?

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim tRow As Long
    Application.Calculation = xlCalculationManual
    For r = 6 To Range("A" & Rows.Count).End(xlUp).Row
    If Range("A" & r) <> "" Then _
    Range("F5").Resize(1, 37).Copy Range("F" & r)
    Next r: Application.Calculation = xlCalculationAutomatic: End Sub

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: If Then Macro for copying formulas please

    In my code there is no tRow it's r instead so change:

    Please Login or Register  to view this content.
    To :
    Please Login or Register  to view this content.
    But: you should use my code as posted rather than an event.

    ** And, thanks for the rep!
    Last edited by xladept; 06-05-2018 at 12:12 AM.

  11. #11
    Forum Contributor
    Join Date
    01-28-2013
    Location
    Spencerport, NY
    MS-Off Ver
    Excel 2016
    Posts
    270

    Re: If Then Macro for copying formulas please

    Thank you XLADEPT ! Works like a charm !

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: If Then Macro for copying formulas please

    You're welcome!

  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,885

    Re: If Then Macro for copying formulas please

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

+ 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. Macro not copying formulas in to new cells
    By b_rianv in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-27-2014, 04:22 PM
  2. Macro code for copying formulas till the last non-empty cell
    By Zozika in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-28-2013, 08:47 AM
  3. Replies: 3
    Last Post: 04-11-2013, 01:29 PM
  4. Replies: 1
    Last Post: 06-29-2012, 01:16 PM
  5. Copying Formulas using Macro
    By Lewis2010 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-12-2011, 02:37 PM
  6. Excel Macro to Add Line while Copying Formats/Formulas
    By muckem333 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-18-2009, 01:54 PM
  7. Macro for copying formulas + inserting rows
    By Marco-Kun in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-25-2009, 09:41 PM

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