Forum Discussion
neurtron1080
Aug 09, 2022Copper Contributor
How to make a macro that updates a summary table with inputs
Hello All, I am attempting to make a macro that can take inputs from one sheet and update a table on another sheet accordingly. For example, say I run apple orchards and am attempting to keep...
- Aug 09, 2022
Sub apples() Dim i As Long Dim j As Long Dim k As Long Dim m As Long Dim n As Long For i = 6 To 13 If Cells(i, 13) <> "" Then m = Application.match(Cells(5, 13), Columns(1), 0) j = Application.match(Cells(i, 12), Rows(1), 0) Cells(m, j).Value = Cells(i, 13).Value Cells(m, 2).Value = Cells(4, 13).Value k = Application.match(Cells(i, 12), Worksheets("sheet2").Rows(1), 0) n = Worksheets("sheet2").Range("A" & Rows.Count).End(xlUp).Row Worksheets("sheet2").Cells(n + 1, 1).Value = Cells(5, 13).Value Worksheets("sheet2").Cells(n + 1, k).Value = Cells(i, 13).Value Worksheets("sheet2").Cells(n + 1, 2).Value = Cells(4, 13).Value Else End If Next i End Sub
In the attached file you can click the button in cell L2 to run the macro. The history of all prices is in sheet2. The summary table is in sheet1 and the input range is M4:M13 in sheet1. The number of types and apple orchards can be adapted as required.
neurtron1080
Aug 09, 2022Copper Contributor
Thanks a lot! This is really helpful. Is there a way to make the inputs and the button on a different sheet than the outsputs so that it isn't all on the same one? Wasn't sure how to do that. Either way I appreciate it!
OliverScheurich
Aug 10, 2022Gold Contributor
You are welcome. In the attached file there are seperate sheets for input, summary and history.