Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2013
    Posts
    2

    Unanswered: Getting a macro to assume conditions

    Hi guys i was wondering if there be a way to select a columns in a specific way ; for example if target column = 2 then ranges A2:N2 will be selected i need this to be repeated for other columns without specifying the target column. The code i'm using is :

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Target.Column = 1 Then
    Sheet2.Activate
    ActiveSheet.Range("A1:N1").Select
    Else
    Exit Sub
    End If
    End Sub

  2. #2
    Join Date
    Sep 2008
    Location
    London, UK
    Posts
    511
    Do you mean something like this?
    Code:
    Private Sub Worksheet_BeforeDoubleClick( _
                ByVal Target As Range, Cancel As Boolean)
     
        Sheet2.Select
        Sheet2.Range("A" & Target.Column & ":N" & Target.Column).Select
     
    End Sub

  3. #3
    Join Date
    Jan 2013
    Posts
    2
    Quote Originally Posted by Colin Legg View Post
    Do you mean something like this?
    Code:
    Private Sub Worksheet_BeforeDoubleClick( _
                ByVal Target As Range, Cancel As Boolean)
     
        Sheet2.Select
        Sheet2.Range("A" & Target.Column & ":N" & Target.Column).Select
     
    End Sub
    Yes this is correct to a certain extent but when i want it to repeat for all other columns making similar references is that possible ? like for example column "A2" refers to A2:N2 ? and so on .

Posting Permissions

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