How do you know when to stop?
I used the last entry in column A in this sample:
Option Explicit
Private Sub Worksheet_Activate()
Dim myCell As Range
Dim myRng As Range
With Me
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With
On Error Resume Next
Application.EnableEvents = False
For Each myCell In myRng.Cells
If myCell.Value = Me.Range("ae1").Value Then
myCell.Offset(0, 1).Value = Me.Range("ad1").Value
End If
Next myCell
Application.EnableEvents = True
On Error GoTo 0
End Sub
short_n_curly wrote:
basically i have this code
Private Sub Worksheet_Activate()
If Range("AE1") = Range("A1") Then
Range("A1").Offset(0, 1) = Range("AD1")
Else
If Range("AE1") = Range("A2") Then
Range("A2").Offset(0, 1) = Range("AD1")
End If
End If
End Sub
so that when the worksheet is activated it will check cell a1 to see if
it equals cell ae1
if so then it will place the value in cell ad1 to the next cell i.e b1
if this is false it will move on to cell a2 with the same criteria
however it would be impractical to persue with the currant code even
though it works due to the fact that there may be several thousand
entries, is there a loop code that would change the variables as i have
never used loops before i am a bit lost
your help would be much appreciated thanks
--
short_n_curly
------------------------------------------------------------------------
short_n_curly's Profile: http://www.excelforum.com/member.php...o&userid=21576
View this thread: http://www.excelforum.com/showthread...hreadid=384154
--
Dave Peterson