Results 1 to 5 of 5

Add formula if adjacent cell has name in it but remove formula in adjacent cell is blank

Threaded View

  1. #1
    Registered User
    Join Date
    06-25-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2019 / 365
    Posts
    71

    Add formula if adjacent cell has name in it but remove formula in adjacent cell is blank

    Hi,
    I'm close to what I need but my problem is although I've ammended this code to enter the Rand() formula if a name is entered in the adjacent cell. But it's not removing the formula if I remove the name from col A (I'm building a random draw so the amount of names can change).
    can anyone help please?

    Name col A3:A35

    Formula Col B3:B35



    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
         
        Dim B As Range
         
        Application.ScreenUpdating = False
         
        For Each B In Range("B3:B35")
            If Intersect(ActiveCell, Range("A3:A35")) Is Nothing Then
                Exit Sub 'active cell is not in the range of input cells
            Else
                If B.Offset(0, -1) <> vbNullString Then
                    B.Value = "=Rand()"
            Else
            
                End If
            End If
             
        Next B
         
        Application.ScreenUpdating = True
         
    End Sub
    Last edited by How How; 05-16-2013 at 08:23 AM. Reason: re-word

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