+ Reply to Thread
Results 1 to 6 of 6

Adding Else into an If statement

Hybrid View

kchm_2000 Adding Else into an If... 10-18-2011, 06:26 AM
TMS Re: Adding Else into an If... 10-18-2011, 06:43 AM
Marcol Re: Adding Else into an If... 10-18-2011, 06:46 AM
snb Re: Adding Else into an If... 10-18-2011, 07:14 AM
kchm_2000 Re: Adding Else into an If... 10-18-2011, 11:39 PM
TMS Re: Adding Else into an If... 10-19-2011, 02:08 AM
  1. #1
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Adding Else into an If statement

    Try this
    Public Sub NT_comment()
        Dim c_ell As Range, Date_Ref As Date, S_heet As Worksheet, c_ell2 As Range
    
        For Each S_heet In ActiveWorkbook.Sheets
            If Left(S_heet.Name, 3) = "ACD" Then
                With S_heet
                    For Each c_ell In .Range("D2:D" & .Range("D" & .Rows.Count).End(xlUp).Row)
                        If c_ell = "C to BBNT" Or c_ell = "Will C SD" Then
                            c_ell.Offset(0, 1) = "OK"
                        Else
                            If c_ell <> "" Then c_ell.Offset(0, 1) = "Not OK"
                        End If
                    Next c_ell
                End With
            End If
        Next S_heet
    End Sub
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Adding Else into an If statement

    Sub snb()
     For Each sh In Sheets
       If Left(sh.Name, 3) = "ACD" Then
        For Each cl In sh.Cells(2, 4).Resize(sh.Cells(Rows.Count, 2).End(xlUp).Row - 1)
         cl.Offset(, 1).Value = IIf(cl = "C to BBNT" Or cl = "Will C SD", "", "Not ") & "OK"
        Next
       End If
     Next
    End Sub



+ 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