I have a fully functioning macro which multiplies numbers entered it a range of cells by -1
This works great if I manually enter the figures however the data will either be copy and pasted in or be pasted from another sheet in the workbook via a copy/paste macro triggered by clicking a button on the sheet which the data is pasted into (code below)
Both codes are worksheet_change events however as there are multiple on this sheet they are run under one change event:
I am completely unable to find a working way to do this without recording a macro in which i click on every single cell and hitting enter in order to trigger the macro on that individual cell. I would like this to happen automatically when the cells are populated with pasted data.
A final note, not all cells will be populated all of the time so it is not possible to trigger the macro by detecting a change in value of one specific cell.
Any suggestions would be greatly appreciated!
Thanks!
Code:
'MINUS FIG COSTSPrivate Sub Macro43(ByVal Target As Range)
If Intersect(Target, Range("U13:X156")) Is Nothing Then Exit Sub
If Target.Count > 1 Then Exit Sub
If Target.Value > 0 Then Target = Target.Value * -1
End Sub
This works great if I manually enter the figures however the data will either be copy and pasted in or be pasted from another sheet in the workbook via a copy/paste macro triggered by clicking a button on the sheet which the data is pasted into (code below)
Code:
'auto populate
Private Sub Macro41(ByVal Target As Range)
On Error GoTo Whoa
If Target.Cells.CountLarge > 1 Then Exit Sub
Dim wsI As Worksheet, wsO As Worksheet
Dim lRow As Long, nCol As Long
Dim sSrch As String
Dim aCell As Range, Rng As Range
Set wsI = ThisWorkbook.Sheets("Schedule")
Set wsO = ThisWorkbook.Sheets("Tenancy Detail")
application.EnableEvents = False
If Not Intersect(Target, Range("A6:AE6")) Is Nothing Then
sSrch = Cells(6, Target.Column).Value
Set aCell = wsI.Rows(6).Find(What:=sSrch, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not aCell Is Nothing Then
nCol = aCell.Column
lRow = wsI.Cells(wsI.Rows.Count, nCol).End(xlUp).Row
Set Rng = wsI.Range(wsI.Cells(7, nCol), wsI.Cells(lRow, nCol))
End If
If Not Rng Is Nothing Then
Range(Cells(7, Target.Column), Cells(Rows.Count, Target.Column)).ClearContents
Rng.Copy
Cells(7, Target.Column).PasteSpecial xlPasteValues
End If
End If
Letscontinue:
application.EnableEvents = True
Exit Sub
Whoa:
MsgBox Err.Description
Resume Letscontinue
Exit Sub
End Sub
Both codes are worksheet_change events however as there are multiple on this sheet they are run under one change event:
Code:
Private Sub Worksheet_Change(ByVal Target As Range) Macro41 Target
Macro42 Target
Macro43 Target
.....etc
I am completely unable to find a working way to do this without recording a macro in which i click on every single cell and hitting enter in order to trigger the macro on that individual cell. I would like this to happen automatically when the cells are populated with pasted data.
A final note, not all cells will be populated all of the time so it is not possible to trigger the macro by detecting a change in value of one specific cell.
Any suggestions would be greatly appreciated!
Thanks!