I'm writing a workbook that will pull external data into it via CSV. It will then populate cells in the workbook.
However, it has to be Sales Person proof. So, when a sales person modifies a cell, it needs to populate the similar cells on other sheets. I have a sheet named Input (Sheet3), which holds all of these values. This took me to using VBA to handle the cell (re)population. So when a sales person edits something like 'Customer Name' on one sheet, every 'Customer Name' on other sheets will be changed.
Here's what I've got. The problem I'm having is that when I change G8 in Sheet14, I get an error that states "Object Required". Debugging takes me to Line12 on Sheet3; hovering over the code, reveals "CallingSheet = Empty". Am I referencing something wrong? Comparing objects incorrectly? Is there an easier way to do all this and still be 'idiot proof'?
ThisWorkbook
Module1
Sheet14
Sheet3
However, it has to be Sales Person proof. So, when a sales person modifies a cell, it needs to populate the similar cells on other sheets. I have a sheet named Input (Sheet3), which holds all of these values. This took me to using VBA to handle the cell (re)population. So when a sales person edits something like 'Customer Name' on one sheet, every 'Customer Name' on other sheets will be changed.
Here's what I've got. The problem I'm having is that when I change G8 in Sheet14, I get an error that states "Object Required". Debugging takes me to Line12 on Sheet3; hovering over the code, reveals "CallingSheet = Empty". Am I referencing something wrong? Comparing objects incorrectly? Is there an easier way to do all this and still be 'idiot proof'?
ThisWorkbook
Code:
Public CallingSheet As Worksheet
Module1
Code:
Public Type SheetCellRef
RefSheet As Worksheet
RefCell As Range
End Type
Sheet14
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Set CallingSheet = Sheet14
Sheet3.Range("B84") = Range("G8")
End Sub
Sheet3
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address
Case "$B$84"
Dim AffectedSheets(1 To 2) As Module1.SheetCellRef
Set AffectedSheets(1).RefSheet = Sheet14
Set AffectedSheets(1).RefCell = Range("G8")
Set AffectedSheets(2).RefSheet = Sheet15
Set AffectedSheets(2).RefCell = Range("A7")
For i = 1 To 2
If Not AffectedSheets(i).RefSheet Is CallingSheet Then 'Line12
AffectedSheets(i).RefSheet.Range(AffectedSheets(i).RefCell) = Range("B84")
End If
Next i
Case Else
MsgBox "Nope" 'If nothing matches
End Select
End Sub