VBA Code to Work down a list, calc a result, add result to bottom of new list

JamesGilchrist

New Member
Joined
Apr 12, 2011
Messages
13
Hi All,

Any help here would be appreciated greatly.

CODE SEQUENCE
1 Copy Item A from List A
2 Paste flat to B2
3 Recalculate the result to update C2
4 Copy range B2:C2
5 Paste flat to bottom of List B
6 Goto next cell on List A
Repeat steps 1-6
Stop at bottom of List A

[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]INPUTS[/TD]
[TD]CALCULATION[/TD]
[TD][/TD]
[TD]OUTPUTS[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]List A[/TD]
[TD]Item A[/TD]
[TD]Result A[/TD]
[TD]List B[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Item A[/TD]
[TD][/TD]
[TD][/TD]
[TD]Item A[/TD]
[TD]Result A[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Item B[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Item C[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Item D[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Re: "3 Recalculate the result to update C2"???????
 
Upvote 0
A couple possibilities.
Don't know what the calculation is about.
If it is set to automatic, it doesn't need any help with code.
Or am I missing something here?
Code:
Sub AAAAA()
Dim c As Range
    For Each c In Range("A3:A" & Cells(Rows.Count, 1).End(xlUp).Row)
        With c
            .Offset(-1, 1).Value = c.Value
            .Offset(, 3).Resize(, 2).Value = .Offset(-1, 1).Resize(, 2).Value
        End With
    Next c
End Sub

Code:
Sub AAAAB()
Dim c As Range
    For Each c In Range("A3:A" & Cells(Rows.Count, 1).End(xlUp).Row)
        Cells(Rows.Count, 2).End(xlUp).Offset(1).Value = c.Value
        Cells(Rows.Count, 4).End(xlUp).Offset(1).Resize(, 2).Value = Cells(Rows.Count, 2).End(xlUp).Resize(, 2).Value
    Next c
End Sub
 
Upvote 0
Thanks for your help, but it's not behaving as expected.
The macro needs to cycle down the items in List A, pasting each Item sequentially into B2 so they can have the results calculated, then past flat each item and it's result at the bottom of list B, and stop when it gets to the bottom of list A. List B will be on a separate tab.

Watching the macro run live..you would see each item in list A be pasted to B2, then B2 and C2 pasted flat at the bottom of list, then the macro would go to the next item on list A and repeat until it reaches the end. List B would be accumulated down the page as the macro runs through each item (iteration) in list List A

The calculation between cells and B2 and C2 in reality will be a major work book that will have 25 different results, and there will be 400+ items in list A.
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,117
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top