Results 1 to 12 of 12

repeating a macro in every row (for multiple cells)

Threaded View

hluk repeating a macro in every... 03-26-2012, 08:28 PM
rylo Re: repeating a macro in... 03-26-2012, 09:04 PM
hluk Re: repeating a macro in... 03-26-2012, 10:46 PM
rylo Re: repeating a macro in... 03-26-2012, 11:21 PM
hluk Re: repeating a macro in... 03-27-2012, 12:51 AM
rylo Re: repeating a macro in... 03-27-2012, 01:04 AM
hluk Re: repeating a macro in... 03-27-2012, 01:36 AM
rylo Re: repeating a macro in... 03-27-2012, 05:43 PM
hluk Re: repeating a macro in... 03-28-2012, 05:09 PM
rylo Re: repeating a macro in... 03-28-2012, 05:26 PM
hluk Re: repeating a macro in... 03-28-2012, 05:36 PM
hluk Re: repeating a macro in... 03-30-2012, 03:16 AM
  1. #1
    Registered User
    Join Date
    07-09-2008
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    91

    repeating a macro in every row (for multiple cells)

    hi!

    I have been looking around the forum and found this thread to the the closest what I am trying to achieve: http://www.excelforum.com/excel-prog...every-row.html

    Basically I have two worksheets, one labeled "data" and the other labeled "calc".

    For each row of "data" starting from row 2, I need to copy 5 values (columns AA, L, I, M, P) into the "calc" worksheet (cells D11, D12, H11, H12, H13) respectively.

    Then the "calc" sheet automatically does the calculations and we get the result in R10 of the "calc" sheet.

    Lastly this resulting value R10 needs to be copied back to the "data" sheet in column AB of each row.

    I have recorded the macro doing this for the row 2 as per below:

    Sub Macro1()
    '
    ' Macro1 Macro
    '
    
    '
        Sheets("data").Select
        Range("AA2").Select
        Selection.Copy
        Sheets("calc").Select
        Range("D11").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("data").Select
        Range("L2").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("calc").Select
        Range("D12").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("data").Select
        Range("I2").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("calc").Select
        Range("H11").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("data").Select
        Range("M2").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("calc").Select
        Range("H12").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("data").Select
        Range("P2").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("calc").Select
        Range("H13").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Range("R10").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("data").Select
        Range("AB2").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Range("AA14").Select
    End Sub
    I have tried modifying the code to make it repeat, but no luck...

    Is there an easy way to adapt what was posted in http://www.excelforum.com/excel-prog...every-row.html to suit what I am trying to do?

    Thank you so much in advanced for your help!
    Last edited by hluk; 03-28-2012 at 05:37 PM.

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