M
Mark Hanley
Hi
I'm trying to create a macro that will do the following:
When the user changes a value or values in column 'B', the macro will
iterate through all cells in columns 'C' to 'AO' but only in the same
row(s) that were changed in column 'B'.
So basically, whatever row or rows got changed, those same rows but
columns C to AO will be altered. The macro is actually just applying
some simple formatting to those cells.
Here's what I have so far and it fails on 'theRow = Target.Rows(i)':
Excerpt
*****************************************************************
Dim theCell As Range
Dim theRow As Range
Dim i As Integer
For i = 1 To Target.Rows.Count
theRow = Target.Rows(i) ' <------------------Throws up
error 'Object variable or With block variable not set'
For Each theCell In Intersect(Range("C1:AO35"), theRow)
If theCell.Value > 0 Then
'Is a multiple of 6 - GOLD
If theCell.Value Mod 6 = 0 Then
Call setGold(theCell)
Else
'Is a multiple of 3 but not a multiple of 6 - SILVER
If (theCell.Value Mod 3) = 0 Then Call setSilver
(theCell)
End If
End If
Next theCell
Next i
***************************************************************************
*
Why can't I just iterate through a Rows collection?
Any help would be appreciated!
Mark
I'm trying to create a macro that will do the following:
When the user changes a value or values in column 'B', the macro will
iterate through all cells in columns 'C' to 'AO' but only in the same
row(s) that were changed in column 'B'.
So basically, whatever row or rows got changed, those same rows but
columns C to AO will be altered. The macro is actually just applying
some simple formatting to those cells.
Here's what I have so far and it fails on 'theRow = Target.Rows(i)':
Excerpt
*****************************************************************
Dim theCell As Range
Dim theRow As Range
Dim i As Integer
For i = 1 To Target.Rows.Count
theRow = Target.Rows(i) ' <------------------Throws up
error 'Object variable or With block variable not set'
For Each theCell In Intersect(Range("C1:AO35"), theRow)
If theCell.Value > 0 Then
'Is a multiple of 6 - GOLD
If theCell.Value Mod 6 = 0 Then
Call setGold(theCell)
Else
'Is a multiple of 3 but not a multiple of 6 - SILVER
If (theCell.Value Mod 3) = 0 Then Call setSilver
(theCell)
End If
End If
Next theCell
Next i
***************************************************************************
*
Why can't I just iterate through a Rows collection?
Any help would be appreciated!
Mark