+ Reply to Thread
Results 1 to 2 of 2

Can't change the range in VBA code

Hybrid View

  1. #1
    Registered User
    Join Date
    11-09-2008
    Location
    Amsterdam
    Posts
    12

    Can't change the range in VBA code

    Hi

    Sorry for the earlier post, but hope this is following the roules!

    Where do I change the range in this VBA code? The range hase to be E14:G214 as below but it's not working.

    Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    If Not Intersect(Target, Range("E14:G214")) Is Nothing Then
        With Target
        Select Case .Column
            Case 1
                If IsDate(.Cells) And IsNumeric(.Offset(0, 2)) And Not IsEmpty(.Offset(0, 2)) Then
                    .Offset(0, 1).Value = .Value + .Offset(0, 2).Value
                End If
            Case 2
                If IsDate(.Cells) And IsDate(.Offset(0, -1)) Then
                    .Offset(0, 1).Value = .Value - .Offset(0, -1).Value + 1
                    .Offset(0, 1).NumberFormat = "General"
                End If
             Case 3
                If IsNumeric(.Cells) And IsDate(.Offset(0, -2)) And Not IsEmpty(.Cells) Then
                    .Offset(0, -1).Value = .Offset(0, -2).Value + .Value - 1
                End If
        End Select
        End With
    End If
    Application.EnableEvents = True
    End Sub

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    That range is looking at Col 5,6 & 7 so change you're select case from 1,2 & 3 to Col 5,6 & 7

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

+ 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