Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need Help Expanding Macro
I need help expanding the function of a macro I have written. Essentially
what this macro does is start at the top of a column and adds two cells together to see if they match a number that is input by the user. It starts with row1 and row2, then row1 and row3, etc. until it has checked to the bottom of the column. I would like to expand this out so that it will run through checking 2 rows, then 3, then 4, etc up to 9 or 10. I can write this out in multiple loops, but I would like to know if there is a faster/simpler way to do it. I will paste the code below so you can see what I am doing. If there is a function or some other way to do this, I would be greatful. My ultimate goal is just to be able to enter a number into an input box and have excel go through all the iterations of the column to find the sum I am looking for in all the possible combinations. Sub combo_add() 'Application.ScreenUpdating = False x = (ActiveCell.Row - 1) * 256 + ActiveCell.Column y = x + 256 z = Application.InputBox(prompt:="Input Total", Type:=1) aa = 1 Do Until Cells(x).Value = "" Do Until Cells(y).Value = "" Cells(x).Select a = Cells(x).Value b = Cells(y).Value If a + b = z Then Cells(x + 1) = aa Cells(y + 1) = aa aa = aa + 1 End If y = y + 256 Loop x = x + 256 y = x + 256 Loop MsgBox aa - 1 Range("A1").Select End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
expanding a macro to do more | Excel Discussion (Misc queries) | |||
Expanding Formulas | Excel Worksheet Functions | |||
Expanding cells again | Excel Programming | |||
expanding IF | Excel Programming | |||
Expanding Code | Excel Programming |