+ Reply to Thread
Results 1 to 3 of 3

Modify IF statements in a range using a macro

  1. #1
    Registered User
    Join Date
    09-23-2016
    Location
    Chicago, Illinois
    MS-Off Ver
    MS Excel 2010
    Posts
    2

    Modify IF statements in a range using a macro

    I have 30 cells in a worksheet named "List". The cells are arranged in a row from Columns C:AF. Each cell contains a IF statement containing a cell reference in Sheet1 (same workbook). I want to copy the IF statements and insert them into a different row with all the same arguments EXCEPT increase the sheet reference by 1. Can this be done? Below is a sample of the IF statements in Column C:E

    =IF('Sheet1'!$I$26="",0,'Sheet1'!$I$26)
    =IF($C3=0,"",IF('Sheet1'!AM40="",0,'Sheet1'!AM40))
    =IF($C3=0,"",IF('Sheet1'!AP40="",0,'Sheet1'!AP40))

    In the example above I want to copy the IF statements and change the reference to Sheet1 by one to make it Sheet2 and insert the new IF statements into a new row. Later the same process will extend to newer rows with references to Sheet3, Sheet4, Sheet5 etc. etc.

    Thank you,

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Modify IF statements in a range using a macro

    When you copy the formula from one row to another does the reference to the row in Sheet1 to be changed: 40 change to ??
    Have you seen to use Control F (Find) with Sheet1 and replace by Sheet2
    Last edited by PCI; 09-28-2016 at 01:44 PM. Reason: Typo
    - Battle without fear gives no glory - Just try

  3. #3
    Registered User
    Join Date
    09-23-2016
    Location
    Chicago, Illinois
    MS-Off Ver
    MS Excel 2010
    Posts
    2

    Re: Modify IF statements in a range using a macro

    PCI Brilliant!! Such an easy and simple way to work around the issue. You are fabulous!! Thank you!

+ 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] Modify Macro to include cells in range instead of one cell
    By fpt264 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-05-2016, 05:44 PM
  2. Help to modify a macro and insert a defined name range within an array
    By brosewall in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-23-2014, 12:23 PM
  3. [SOLVED] Need macro modify for copy range one sheet to another
    By nur2544 in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 12-26-2012, 12:09 PM
  4. [SOLVED] Modify insert rows macro if out if selected range
    By kstrick99999 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-07-2012, 11:31 AM
  5. Macro Edit - Need to swap a range of cells and cannot modify VBA - Please Help
    By Mark McInerney in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2012, 11:24 AM
  6. modify range macro
    By var in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-22-2011, 06:31 PM
  7. how to modify this if(len) to have two if statements?
    By Johnathan in forum Excel General
    Replies: 1
    Last Post: 07-09-2011, 01:43 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