+ Reply to Thread
Results 1 to 4 of 4

Errors on If Statements

Hybrid View

  1. #1
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    Try:

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim RngCell As Range
    Dim DrpDown As String
    
    If Target.Column = 1 And Target.Row = 5 Then
        DrpDown = Target.Value
        Set RngCell = Cells(2, 5)
    End If
        
        If DrpDown = "$/square foot" Then
        With RngCell
            .NumberFormat = "$#,##0.00"
      
        ElseIf DrpDown = "%/construction cost" Then
        With RngCell
            .NumberFormat = "0.0%"
        End If
        
    End Sub
    EDIT: You also didn't "End With" in either case.

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    Thanks to both of you! I knew about End With's, just had a duh moment. I like your more concise code, shg.

    ChemistB
    back to the drawing board.

+ 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