Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Trigger macro when range entry complete
I have a range of cells; non-contiguous; namely
("D109, C111:K111, C114:K114") What I would like to achieve is that when this range is complete with data to have a macro run - lets call it "SetHR". The range of cells is in a sheet called ("Current Round"). Now my thinking was to trigger the macro in the Worksheet_Change event - but only trigger it when all cells in the range contain data (which is a mixture of text and numeric), and the focus has now moved outwith the above range. Furthermore not to run "SetHR" until any further change occurs to the above range. Hope this makes sense. Any thoughts? Sandy |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Trigger macro when range entry complete
Sandy,
Right click your sheet tab, view code and paste this in. When all cells in your range are populeted it call your macro and won't call it again until a cell changes. Private Sub Worksheet_Change(ByVal Target As Range) Dim MyRange As Range Dim FilledCells As Long, TotCells As Long Set MyRange = Range("D109, C111:K111, C114:K114") If Intersect(Target, MyRange) Is Nothing Then Exit Sub FilledCells = WorksheetFunction.CountA(MyRange) TotCells = MyRange.Cells.Count If FilledCells = TotCells Then Call SetHR End If End Sub Mike "Sandy" wrote: I have a range of cells; non-contiguous; namely ("D109, C111:K111, C114:K114") What I would like to achieve is that when this range is complete with data to have a macro run - lets call it "SetHR". The range of cells is in a sheet called ("Current Round"). Now my thinking was to trigger the macro in the Worksheet_Change event - but only trigger it when all cells in the range contain data (which is a mixture of text and numeric), and the focus has now moved outwith the above range. Furthermore not to run "SetHR" until any further change occurs to the above range. Hope this makes sense. Any thoughts? Sandy |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Trigger macro when range entry complete
Mike
Thank you very much, works perfectly. Sandy "Mike H" wrote in message ... Sandy, Right click your sheet tab, view code and paste this in. When all cells in your range are populeted it call your macro and won't call it again until a cell changes. Private Sub Worksheet_Change(ByVal Target As Range) Dim MyRange As Range Dim FilledCells As Long, TotCells As Long Set MyRange = Range("D109, C111:K111, C114:K114") If Intersect(Target, MyRange) Is Nothing Then Exit Sub FilledCells = WorksheetFunction.CountA(MyRange) TotCells = MyRange.Cells.Count If FilledCells = TotCells Then Call SetHR End If End Sub Mike "Sandy" wrote: I have a range of cells; non-contiguous; namely ("D109, C111:K111, C114:K114") What I would like to achieve is that when this range is complete with data to have a macro run - lets call it "SetHR". The range of cells is in a sheet called ("Current Round"). Now my thinking was to trigger the macro in the Worksheet_Change event - but only trigger it when all cells in the range contain data (which is a mixture of text and numeric), and the focus has now moved outwith the above range. Furthermore not to run "SetHR" until any further change occurs to the above range. Hope this makes sense. Any thoughts? Sandy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Insert formulas on data entry trigger | Excel Programming | |||
matched entry complete not working | Excel Programming | |||
automatically add borders to a cell after entry is complete | Excel Discussion (Misc queries) | |||
Trigger macro if an Activecell is within a specific Range | Excel Programming | |||
Trigger macro if an Activecell is within a specific Range | Excel Programming |