Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Inserting new rows with mixed formulas and data w/o copying data
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Bill Manville  
View profile  
 More options Mar 11 1998, 3:00 am
Newsgroups: microsoft.public.excel.programming
From: Bill-Manvi...@msn.com (Bill Manville)
Date: 1998/03/11
Subject: Re: Inserting new rows with mixed formulas and data w/o copying data

On 11 Mar 1998 21:30:01 GMT, dmcritc...@aol.com (DMcRitchie) wrote:

>I would like to insert rows into my spreadsheet and fixup the formulas that
>might otherwise be destroyed.  I do not want to copy cells with data.  I only
>want to copy the formulas.   If it is not a formula leave or make the cell
>null.

>I am pretty sure that the SOLUTION WILL REQUIRE CHECKING CELLS TO SEE IF
>INSERTED CELL
>IS BELOW A FORMULA OR NOT.  Please keep in mind that a generic solution is
>wanted not a test to match this particular example which only has formulas in
>one column (col E).

>Mark Hill <markh...@charm.net.noSpam>  proposed a solution to a problem
>sometime back that I will use to illustrate what I want and don't want.

>Representation of Original Data
>--C--        --D--   --E--   Formula in E  
>13  0       13       =C2-D2        
>0   14      -1       =E2+C3-D3     <--- Select this row insert 3 lines

>25  0       24       =E3+C4-D4      
>37  0       61       =E4+C5-D5      
>38  0       99       =E5+C6-D6     0's would normally be null cells.  

>Mark's Macro:  (9 non blank lines)

>Sub InsertRowsAndFillFormulas()
>' Re: Insert Rows --   1997/09/24 Mark Hill <markh...@charm.net.noSpam>
>Dim vRows%
>   vRows = Application.InputBox(prompt:="How many rows do you want to add?",
>Title:="Add Rows", default:=1, Type:=1) 'type 1 is number

>   If vRows = False Then Exit Sub
>   'if you just want to add cells and not entire rows then delete ".EntireRow"
>in the following line

>   Selection.Resize(rowsize:=2).Rows(2).EntireRow.Resize(rowsize:=vRows).Inser t
>shift:=xlDown

>   Selection.AutoFill Selection.Resize(rowsize:=vRows + 1), xlFillDefault

     ' to remove the non-formulas

Selection.Offset(1).Resize(vRows).EntireRow.SpecialCells(xlConstants).Clear Contents

>End Sub    

>Results:
>--C--        --D--   --E--   Formula in E  
>13  0       13       =C2-D2        
>0   14      -1       =E2+C3-D3
>-----------------------------------------------------      
>1   15      -15      =E3+C4-D4  Three inserted lines        
>2   16      -29      =E4+C5-D5      
>3   17      -43      =E5+C6-D6
>-------------------------------------------------------    
>25  0       24       =E3+C7-D7   <-- note formula incorrect.    
>37  0       61       =E7+C8-D8      
>38  0       99       =E8+C9-D9      

>This is what I want  "--" represents null cells
>--C--        --D--   --E--   Formula in E  
>13  0       13       =C2-D2        
>0   14      -1       =E2+C3-D3
>-----------------------------------------------------      
>--  --      --       =E3+C4-D4  Three insert lines  
>--  --      --       =E4+C5-D5  "--" are null cells      
>--  --      --       =E5+C6-D6
>-------------------------------------------------------    
>25  0       24       =E6+C7-D7  <- formula is "corrected"      
>37  0       61       =E7+C8-D8    (as if vRows + 2)
>38  0       99       =E8+C9-D9

>After inserting lines the results should show inserted cells below non-formulas
>to be empty, and below formulas to have an inserted formula.  The formula must
>be extended one row additionally to fix the original formula below the inserted
>lines.

If you wrote the formula in E3 as
=OFFSET(E3,-1,0)+C3-D3
and copied it down, you would not need to correct the formula in the
row after the inserted rows.

Bill Manville
Oxford, England
Microsoft Excel - MVP


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.