Reputation: 473
I'm trying to create a Gantt chart type display using only cell values. Formulas will not work due to formatting so I need to have VBA run instead.
I want to loop across the both the columns and rows of a single named range. However, I don't think the VBA format is correct as this errors out "438: Object doesn't support this property or method"
Dim d As Integer
Dim e As Integer
For d = 1 To **Range("PRcal").Cols.Count**
For e = 1 To **Range("PRcal").Rows.Count**
If [Range("PRcal").Cells.(e, d).Value = Range("PRcal").Cells(1, d).Value] Then
Cells(e, d).Value = Cells(e, 1)
End If
Next e
Next d
Any suggestions? Thanks!
Upvotes: 0
Views: 1514
Reputation: 328568
Cols
property - they do have a Columns
propertyif
in Cells.(e,d)
if
This should work fine:
Dim d As Integer
Dim e As Integer
For d = 1 To Range("PRcal").Columns.Count
For e = 1 To Range("PRcal").Rows.Count
If Range("PRcal").Cells(e, d).Value = Range("PRcal").Cells(1, d).Value Then
Cells(e, d).Value = Cells(e, 1)
End If
Next e
Next d
Upvotes: 3