BenRichards
New Member
- Joined
- Apr 7, 2014
- Messages
- 41
Hi guys!
I want this bit of code to keep the cells from C3 to C6 empty if there is "-" in C1 or if the cell in the column A on the same row is empty. If I do it like this:
Private Sub Worksheet_Change(ByVal Target As Range)
Call Macro1
End Sub
Sub Macro1()
For Each cell In Range("C3:C6")
If ActiveSheet.Range("C1").Value = "-" Or Active.cell.Offset(0, -2).Value = "" Then
cell.Value = ""
End If
Next cell
End Sub
I get an error "Object required." I think there's something wrong with the part I've bolded. I've also tested it this way:
If ActiveSheet.Range("C1").Value = "-" Or RC - 2 = "" Then
The VBA-editor accepts that bit of code, but it doesn't seem to work. (I obviously don't know how to use those R[3]C[2]-types of references.)
Does someone know a better alternative for the bolded part? Thank you!
I want this bit of code to keep the cells from C3 to C6 empty if there is "-" in C1 or if the cell in the column A on the same row is empty. If I do it like this:
Private Sub Worksheet_Change(ByVal Target As Range)
Call Macro1
End Sub
Sub Macro1()
For Each cell In Range("C3:C6")
If ActiveSheet.Range("C1").Value = "-" Or Active.cell.Offset(0, -2).Value = "" Then
cell.Value = ""
End If
Next cell
End Sub
I get an error "Object required." I think there's something wrong with the part I've bolded. I've also tested it this way:
If ActiveSheet.Range("C1").Value = "-" Or RC - 2 = "" Then
The VBA-editor accepts that bit of code, but it doesn't seem to work. (I obviously don't know how to use those R[3]C[2]-types of references.)
Does someone know a better alternative for the bolded part? Thank you!
Last edited: