brett1again
New Member
- Joined
- Jun 2, 2022
- Messages
- 10
- Office Version
- 365
- Platform
- MacOS
Hello,
I have a copy row to another sheet macro that I'm using which works fine but when the row is moved to another sheet the sheet reference in one of the formulas is still referencing the name of the sheet it was moved from which causes an error. I'm needing a code that'll help resolve this.
Here is the formula and the reference sheet I'm needing to change after the copy is "Cambridge"
Here is the worksheet macro I'm currently using
Thanks for the help
I have a copy row to another sheet macro that I'm using which works fine but when the row is moved to another sheet the sheet reference in one of the formulas is still referencing the name of the sheet it was moved from which causes an error. I'm needing a code that'll help resolve this.
Here is the formula and the reference sheet I'm needing to change after the copy is "Cambridge"
Excel Formula:
=SUMPRODUCT(ISNUMBER(SEARCH('Formatting Lists'!$A$1:$A$11,Cambridge!U2))*'Formatting Lists'!$B$1:$B$11)+IF($V2>250,($V2-250)*1.5,0)+($W2*8.5)
Here is the worksheet macro I'm currently using
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Oldvalue As String
Dim Newvalue As String
Dim xRng As Range
Dim Lastrow As Long
If Target.Count > 1 Then Exit Sub
On Error GoTo Exitsub
Set xRng = Range("U:U").SpecialCells(xlCellTypeAllValidation)
On Error GoTo 0
If Not Application.Intersect(Target, xRng) Is Nothing Then
Application.EnableEvents = False
Newvalue = Target.Value
Application.Undo
Oldvalue = Target.Value
Target.Value = Newvalue
If Oldvalue <> "" Then
If Newvalue <> "" Then
If Oldvalue = Newvalue Or _
InStr(1, Oldvalue, ", " & Newvalue) Or _
InStr(1, Oldvalue, Newvalue & ",") Then
Target.Value = Oldvalue
Else
Target.Value = Oldvalue & ", " & Newvalue
End If
End If
End If
Application.EnableEvents = True
End If
'********Delete record
If Not Intersect(Target, Range("AD:AD")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Lastrow = Sheets("cambridge completes").Cells(Rows.Count, "AD").End(xlUp).Row + 1
If Target.Value = "CLOSE" Then
Rows(Target.Row).Copy Destination:=Sheets("cambridge completes").Rows(Lastrow)
Rows(Target.Row).Delete
End If
End If
Exitsub:
End Sub
Thanks for the help