+ Reply to Thread
Results 1 to 6 of 6

Code to work on rows 9-220 only

Hybrid View

  1. #1
    Registered User
    Join Date
    07-25-2009
    Location
    South London, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Code to work on rows 9-220 only

    Hi Everyone,
    This is my first post so please go easy on me!
    Private Sub Worksheet_Change(ByVal Target As Range)
    Range("A" & ActiveCell.Row) = Date
    End Sub
    The above code works fine to place a date stamp in column A of any row I input numeric data into however I now wish to restrict this activity to rows 9-220. Can anyone assist me with this please?
    Regards
    Grf

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Code to work on rows 9-220 only

    Assuming that you are inputting your data in column B, try this -
    Option Explicit
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B9:B220")) Is Nothing Then
        Range("A" & Target.Row) = Date
    End If
    End Sub
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Code to work on rows 9-220 only

    to cover entire rows
    Option Explicit
    
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim rcell                 As Range
        On Error GoTo error_handler
        If Not Intersect(Target, Range("9:220")) Is Nothing Then
            Application.EnableEvents = False
            For Each rcell In Intersect(Target, Range("9:220")).Cells
                Range("A" & rcell.Row) = Date
            Next rcell
            Application.EnableEvents = True
        End If
        Exit Sub
    error_handler:
        Application.EnableEvents = True
    End Sub
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Registered User
    Join Date
    07-25-2009
    Location
    South London, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Code to work on rows 9-220 only

    Thanks JP , yes I am actually using C9:Y220, so I will incorporate that in your code. Regards grf

  5. #5
    Registered User
    Join Date
    07-25-2009
    Location
    South London, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Code to work on rows 9-220 only

    Thank you very much Arlette, it works perfectly
    Regards Graham

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Code to work on rows 9-220 only

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

+ 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