With Intersect(Target,cells(i,j) only, the code works fine but adding another statement after OR throws an error saying object or with block variable not set.
Objective: throw a prompt, for copy and paste, at row 86 and row 70 using worksheet event function.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim j As Integer
j = ActiveCell.Column 'basing off activecell made it dynamic
Debug.Print j
If j > 2 Then 'must be more than column b
If Not Intersect(Target, Cells(70, j)) Or Intersect(Target, Cells(86, j)) Is Nothing Then 'there is something
'add a column or not
addCol = MsgBox("You have reached a mandatory field. Would you like to add another project?", vbYesNo + vbQuestion)
If addCol = vbYes Then
Columns(j).Copy (Cells(1, j + 1))
Cells(71, j).Activate 'go to next row within same project column
Cells(2, j + 1).Value = "Input " & (j - 2)
Else
MsgBox "You have decided NOT to add another project!", vbInformation
End If
End If
Else
Exit Sub
End If
End Sub
Bookmarks