I am looking for a code to loop through a named range cells values if they are greater than 9 in sheet1. if the Cells value(>9) is found pass that cell value to sheet2 as calculated value
The format is like: Sheet2.Range(name).Cells.value = Sheet1.Range(name).Cells.value
Currently i managed to check those values in sheet1 and it works.
I am failing to assign the value in sheet2 cellTarget looping
code:
Dim rngSource As Range, cellSource As Range
Dim rngTagert As Range, cellTarget As Range
Set rngSource = Range("SourceRange") 'Sheet1
Set rngTagert = Range("TargetRange") 'Sheet2
For Each cellSource In rngSource
If cellSource.Value >= 9 Then
For Each cellTarget In rngTagert
cellTarget.Value = cellSource.Value - 9
Next cellTarget
Else
cellTarget.Value = cellTarget.Value
End If
Next cellSource
Error says "Invalid Next Control Variable Reference"
Many Thanks
For Each cellSource In rngSource
and TwoNext cell
– Shai Rado