Thread: Tickmark Macro
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Tickmark Macro

Sub ABC()
Dim rng as Range, num as Long
set rng = Intersect(selection.EntireRow,Columns(2))
num = application.Max(Columns(3)) + 1
for each cell in rng
cell.offset(0,1).Value = num
Next
With cells(rows.count,2).end(xlup).offset(3,0)
.offset(0,1).Value = num
.formula = "=Sum(" & rng.Address & ")"
.Formula = .Value
End with
End Sub

Untested, but try the above.

If you selected a value that had been used in a previous summation, this
would overwrite its tick with a new number. I don't know how you would want
that handled. Also, if run a second time, it places the answer two rows
below the last answer. Is that what you want. (other choices would be to
replace the last answer or to put it in the cell below the last answer - in
either case, this would require no blank cells in the original values or a
smarter algorithm for placement).

--
Regards,
Tom Ogilvy


" wrote:

I would like to have a macro that will sum noncontiguous numbers in a
column, place a numbered tickmark to the right of each number, and a
corresponding tickmark to the left of the cell containing the sum
(which would be located two cells below the last cell with a value in
column B). I would like to be able to select the noncontiguous numbers
and then run the macro. So for instance, if column C contained random
values in rows 1 through 10, and I wanted to sum cells B1, B2, B6, and
B10, I would like to be able to select these cells, then run the
macro, which would place (for example) a "1" in C1, C2, C6, and C10,
and then place the sum in B12 (two cells below the last cell with a
value in column B), and would place a "1" in A12. Additionally, I
would like the macro to be able to track the numbers that it places
next to the cells, and increase it each time, so that after running it
the first time, it would place a "2" next to each cell, etc. I know
that this is not your simple record-and-use macro, which is why I
haven't done it. If anyone out there reading this is an accountant/
auditor, you know that this would be useful for ticking and tying, and
its possible that a macro already exists to do this. If you can give
me a hand with this, it would save myself and a lot of new-hires time
on the job. Possible variations to this macro would include requiring
me to enter the number I would like to place next to the cells, or
requiring me to select the cell where I would like to place the sum.
One of the given assumptions to run this macro would be that the
column to the right of the column containing my targeted values would
be empty.