+ Reply to Thread
Results 1 to 5 of 5

Repeat code over 300 rows

  1. #1
    Patrick Simonds
    Guest

    Repeat code over 300 rows

    How can I alter this code so that if performs the function not just on row 2
    but all the way down through row 300. I Am sure I could repeat the code for
    each of the 300 rows but I bet there is a better way.

    Private Sub Worksheet_Calculate()
    Me.Range("A2").Value = Me.Range("D2")
    End Sub



  2. #2
    Tim Williams
    Guest

    Re: Repeat code over 300 rows

    for i=2 to 300
    me.cells(i,1).value=me.cells(i,4).value
    next i

    though it's not clear from your post whether A3 should equal D2 or D3....


    Tim



    "Patrick Simonds" <[email protected]> wrote in message
    news:[email protected]...
    > How can I alter this code so that if performs the function not just on row
    > 2 but all the way down through row 300. I Am sure I could repeat the code
    > for each of the 300 rows but I bet there is a better way.
    >
    > Private Sub Worksheet_Calculate()
    > Me.Range("A2").Value = Me.Range("D2")
    > End Sub
    >




  3. #3
    Patrick Simonds
    Guest

    Re: Repeat code over 300 rows

    Sorry

    Me.Range("A2").Value = Me.Range("D2")
    A3 D3
    A4 A5
    A6 A6

    All the way down to row 300



    "Tim Williams" <saxifrax at pacbell dot net> wrote in message
    news:[email protected]...
    > for i=2 to 300
    > me.cells(i,1).value=me.cells(i,4).value
    > next i
    >
    > though it's not clear from your post whether A3 should equal D2 or D3....
    >
    >
    > Tim
    >
    >
    >
    > "Patrick Simonds" <[email protected]> wrote in message
    > news:[email protected]...
    >> How can I alter this code so that if performs the function not just on
    >> row 2 but all the way down through row 300. I Am sure I could repeat the
    >> code for each of the 300 rows but I bet there is a better way.
    >>
    >> Private Sub Worksheet_Calculate()
    >> Me.Range("A2").Value = Me.Range("D2")
    >> End Sub
    >>

    >
    >




  4. #4
    Patrick Simonds
    Guest

    Re: Repeat code over 300 rows

    Having tried your cod, it does exactly what I need. Thank you


    "Tim Williams" <saxifrax at pacbell dot net> wrote in message
    news:[email protected]...
    > for i=2 to 300
    > me.cells(i,1).value=me.cells(i,4).value
    > next i
    >
    > though it's not clear from your post whether A3 should equal D2 or D3....
    >
    >
    > Tim
    >
    >
    >
    > "Patrick Simonds" <[email protected]> wrote in message
    > news:[email protected]...
    >> How can I alter this code so that if performs the function not just on
    >> row 2 but all the way down through row 300. I Am sure I could repeat the
    >> code for each of the 300 rows but I bet there is a better way.
    >>
    >> Private Sub Worksheet_Calculate()
    >> Me.Range("A2").Value = Me.Range("D2")
    >> End Sub
    >>

    >
    >




  5. #5
    Peter T
    Guest

    Re: Repeat code over 300 rows

    Hi Patrick,

    Me.Range("A2:A301").Value = Me.Range("D2:D301").Value

    The Me qualifier assumes code is in a Worksheet module.

    Regards,
    Peter T

    "Patrick Simonds" <[email protected]> wrote in message
    news:[email protected]...
    > How can I alter this code so that if performs the function not just on row

    2
    > but all the way down through row 300. I Am sure I could repeat the code

    for
    > each of the 300 rows but I bet there is a better way.
    >
    > Private Sub Worksheet_Calculate()
    > Me.Range("A2").Value = Me.Range("D2")
    > End Sub
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1