View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
P Daulton P Daulton is offline
external usenet poster
 
Posts: 8
Default Find value, copy, compute, and more

...and a small adaptation to do the whole column, in the following code is
the same macro as the previous post (the second macro), but commented out
lines added. Remove the initial single quote marks to enable them:

Sub Something2()
'For myrow = 1 To 21
'Cells(myrow, "E").Select
On Error GoTo mistake
a = WorksheetFunction.Match(Selection, Range("A1:A21"), 0)
myyear = Cells(a, "B")
adjyear = Cells(a, "C")
adjsel = Selection.Offset(0, -1)
If adjyear adjsel Then myvalue = adjyear / adjsel Else myvalue = adjsel /
adjyear
Selection.Offset(0, 1) = myyear & "*" & Format(myvalue, "0.00")
mistake:
'Next myrow
End Sub

Pascal