Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Excel Automation

Posted on 2011-09-28
Medium Priority
172 Views
Hello Experts,

A clever expert assisted me with the following formula. However, he appear busy and I was wondering if someone could show me how to make it run dynamically without having to hit F5 or click run?

Sub compile_duplicates()
colStart = "AW"
rowStart = 5
cellStart = colStart & rowStart
For Each c In Range(cellStart & ":" & colStart & (Cells.SpecialCells(xlCellTypeLastCell).Row)).Cells
With WorksheetFunction
colnum = .CountIf(Range(cellStart & ":" & colStart & (Cells.SpecialCells(xlCellTypeLastCell).Row)), c)
If colnum > 0 Then
yaxis = .Substitute(Left(Cells(1, colnum + Range(colStart & 1).Column).Address, .Find("\$", Cells(1, colnum + 1).Address, 2)), "\$", "")
If .CountIf(Range(yaxis & ":" & yaxis), c) < 1 Then
xaxis = .CountA(Range(yaxis & rowStart & ":" & yaxis & Cells.SpecialCells(xlCellTypeLastCell).Row)) + rowStart
Range(yaxis & xaxis) = c
Else
End If
Else
End If
End With
Next c
End Sub

Cheers

Carlton
0
Question by:cpatte7372
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 4
• 2

LVL 24

Expert Comment

ID: 36716790
Carlton - you could make it run every time a cell is changed, or selected, or double-clicked or right-clicked etc. What would you like? If the former, which cell(s) should activate it?
0

LVL 37

Accepted Solution

Neil Russell earned 1000 total points
ID: 36716829

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
compile_duplicates
Application.EnableEvents = True
End Sub

Into the worksheet  code module IF you wanted it fire on EVERY change to that worksheet
0

Author Comment

ID: 36718053
Hello guys,

Sorry for the long delay in responding.

Neil, I'm not sure if it would be a good idea to have formula fired on EVERY change as the spreadsheet is literally changing every second.

Therefore, Stephen, it would be great if you could assist in having the spreadsheet just fire when cell chnages in column AW.

Cheers
0

Author Comment

ID: 36718061
Stephen, the cells tha would activate it would be cells AW5:AW17

Cheers
0

LVL 24

Assisted Solution

StephenJR earned 1000 total points
ID: 36718096
Just add this line in Neilsr's code before the false line.
``````If Intersect(Target, Range("AW5:AW17")) Is Nothing Then Exit Sub
``````
0

Author Comment

ID: 36720399
Neil/Stephen,

Cheers guys
0

Author Closing Comment

ID: 36720402
Cheers guys
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference texâ€¦
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (â€śforceâ€ť) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;â€¦
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaacâ€¦
###### Suggested Courses
Course of the Month5 days, 19 hours left to enroll