+ Reply to Thread
Results 1 to 2 of 2

Can you change the Target reference in Change_Event sub???

Hybrid View

  1. #1
    Registered User
    Join Date
    05-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    83

    Can you change the Target reference in Change_Event sub???

    I have three columns of data that I need to all be numbers. I've figured out how to check there all numbers. but what I need to do is check if the target is in column 1 and if not change the target to be in column one. this is because I have another function which is called up but relies on it being called to the first column due to off set references in the function.

    Any ideas?

    hope that makes sense



    Thanks

  2. #2
    Registered User
    Join Date
    05-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    83

    Re: Can you change the Target reference in Change_Event sub???

    This is the code I have so far, but cant figure out how to change the target range and not sure if it is recognising input into column 2 or 3!

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    
    Dim i As Integer
    
    Application.EnableEvents = False
    
    For i = 1 To 2
    'Check if active column is column A.
        If Target.Column = 1 Then
            If IsNumeric(Target.Value) And Target.Value > 0 Then
                If IsNumeric(Target.Offset(0, 1).Value) And Target.Offset(0, 1).Value > 0 Then
                    If IsNumeric(Target.Offset(0, 2).Value) And Target.Offset(0, 2).Value > 0 Then
                        MsgBox ("All columns contain numbers and you typed in A?")
                    End If
                End If
            End If
    
        'Set target reference to column 1 and loop
        ElseIf Target.Column = 2 Or Target.Column = 3 Then
            'Target.Range = Target.Offset(0, -1)
        End If
    Next i
    
    Application.EnableEvents = True
    
    End Sub
    Thanks

+ 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