+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19

Thread: Select the next column and start on line 4 when a condition is satisfied.

  1. #16
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    423

    Re: Select the next column and start on line 4 when a condition is satisfied.

    It works, but it almost seems counter-intuitive though...I mean it doesn't prompt you the moment you put in a text value in there. It's only when you go back to the cell and then it will tell you you have put in a letter instead of a number.

    That's why I had thought I would put that check in the worksheet change event, but it didn't work...

  2. #17
    Valued Forum Contributor
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    895

    Re: Select the next column and start on line 4 when a condition is satisfied.

    It works exactly what You wished for
    the msbox appears when You just put text in range and accept this with "enter" or select next cell with mouse click

    I do not follow...
    Private Sub Worksheet_Change(ByVal Target As Range)
     
    If Target.Row > 4 And Target.Row < 11 Then
        If Not IsNumeric(Target) Then
            Target.ClearContents
            MsgBox "this is not a number!"
        End If
    End If
    
    End Sub
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        
        Cells.Interior.ColorIndex = xlNone
        Cells.Font.Size = 14
        Cells(2, Target.Column).Interior.ColorIndex = 27
        Cells(Target.Row, 1).Interior.ColorIndex = 26
        
        If Target.Count = 1 Then
        With Target
            .Interior.ColorIndex = 43
            .Font.Size = 18
        End With
        End If
        
        If Target.Row > 11 Then
        Cells(4, Target.Column + 1).Select
        Cells(2, Target.Column + 1).Interior.ColorIndex = 27
        End If
        
    End Sub
    p.s I am going home so this is my last post for couple houres
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  3. #18
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    423

    Re: Select the next column and start on line 4 when a condition is satisfied.

    But when you hit "Enter" or move to next cell, it doesn't tell you right away you have just put in a wrong format. It's only when you go back to the cell it can then prompt you. This is the difference in effect between the worksheet_change and worksheet_selection change.

  4. #19
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    423

    Re: Select the next column and start on line 4 when a condition is satisfied.

    Any ideas Tom?

    do you get what I was saying about the difference between worksheet_change event and worksheet_selectionchange event?

+ 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.2.0