Boomdiddygop
New Member
- Joined
- Oct 3, 2013
- Messages
- 5
Hi, my code is behaving in a way that I did not at all expect.
What I was hoping it would do is go down column A and then apply a label and add a value depending on what is in the cell. If the cell is empty, then it will get a label and then in column B, a number would be added. If the name already exists, then a number would be added to the existing value in column B.
What is happening is I get Error:1004 Application-defined or object-defined error. For some reason the label is also placed in cell E7.
Sheets("Fixture Counter").Activate
For Each c In Range("A2:A" & Range("A1").End(xlDown).Row)
If c.FormulaR1C1 = "" Then
ActiveCell.FormulaR1C1 = Label
ActiveCell.Offset(0, 1).Select
FixtureNumber = Sheets("Fixture Counter").Range(ActiveCell).Value
'Application-defined or object-defined error.
ActiveCell.FormulaR1C1 = FixtureNumber + Added
ElseIf c.FormulaR1C1 = Label Then
ActiveCell.Offset(0, 1).Select
FixtureNumber = Sheets("Fixture Counter").Range(ActiveCell).Value
'It hasn't gotten this far but I'm guessing the same error will occur here.
ActiveCell.FormulaR1C1 = FixtureNumber + Added
End If
Next
If anybody could help me with either problem it would be much appreciated.
What I was hoping it would do is go down column A and then apply a label and add a value depending on what is in the cell. If the cell is empty, then it will get a label and then in column B, a number would be added. If the name already exists, then a number would be added to the existing value in column B.
What is happening is I get Error:1004 Application-defined or object-defined error. For some reason the label is also placed in cell E7.
Sheets("Fixture Counter").Activate
For Each c In Range("A2:A" & Range("A1").End(xlDown).Row)
If c.FormulaR1C1 = "" Then
ActiveCell.FormulaR1C1 = Label
ActiveCell.Offset(0, 1).Select
FixtureNumber = Sheets("Fixture Counter").Range(ActiveCell).Value
'Application-defined or object-defined error.
ActiveCell.FormulaR1C1 = FixtureNumber + Added
ElseIf c.FormulaR1C1 = Label Then
ActiveCell.Offset(0, 1).Select
FixtureNumber = Sheets("Fixture Counter").Range(ActiveCell).Value
'It hasn't gotten this far but I'm guessing the same error will occur here.
ActiveCell.FormulaR1C1 = FixtureNumber + Added
End If
Next
If anybody could help me with either problem it would be much appreciated.