+ Reply to Thread
Results 1 to 3 of 3

Inserting formula not the cell value every other row

Hybrid View

m-steele@shaw.ca Inserting formula not the... 08-27-2012, 12:39 AM
patel45 Re: Inserting formula not the... 08-27-2012, 02:05 AM
m-steele@shaw.ca Re: Inserting formula not the... 08-27-2012, 03:25 AM
  1. #1
    Registered User
    Join Date
    08-03-2012
    Location
    canada
    MS-Off Ver
    Excel 2003
    Posts
    17

    Inserting formula not the cell value every other row

    I am trying to get the following macro to work but it has two issues that i cant figure out how to fix.

    1. It needs to copy and insert the cell formulas not the cell values.

    2. For some reason when i run the macro is starts processing from the bottom of the sheet up. This might be fine but im not sure, it doesn't seem to be working so it might be causing issues.


    What this macro should do is copy the formulas (not the values) of the 3rd and 4th rows from column A to the 50th column of my document.
    It then inserts these two rows of data without replacing any other existing rows every second row till the end of the document. The document already contains about 7000 rows of data and the copied cells from rows 3 and 4 need to be inserted between every row of existing data.
    My sheet is organized as follows

    Header Row
    2nd Row
    3rd Row must be copied
    4th Row must be copied
    5th Row
    6th Row
    7th Row
    ...
    7000th row

    The copied cells should go between every row of data till the end of the sheet.

    My code is as follows:

    Sub insertMain()
      Dim x
        Application.ScreenUpdating = 0
         x = Cells(3, 1).Resize(2, 50).Value
          For i = Cells(Rows.Count, 2).End(xlUp).Row To 1 Step -1
          j = 1
            Do Until j > 2
              Cells(i, 1).EntireRow.Insert
              j = j + 1
            Loop
             Cells(i, 1).Resize(2, 50).Value = x
          Next
        Application.ScreenUpdating = 1
    End Sub

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Inserting formula not the cell value every other row

    Please do not propose macro, explain better what you want, attach a sample before and after
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    08-03-2012
    Location
    canada
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Inserting formula not the cell value every other row

    Im not really sure what you mean? This is not a proposed macro... this is what i have come up with so far and need help with. If you have a better solution I would love to hear it.

    Im trying to learn this stuff so working from what i have helps.

    Anyways, I have attached a sample which might make it easier. See below.


    Insert formula example.xlsm

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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