Results 1 to 7 of 7

need help with if or and mid statement

Threaded View

erickmcburger need help with if or and mid... 09-19-2014, 05:40 AM
huuthang_bd Re: need help with if or and... 09-19-2014, 05:55 AM
erickmcburger Re: need help with if or and... 09-19-2014, 08:43 AM
pareshj Re: need help with if or and... 09-19-2014, 05:58 AM
Marc L Re: need help with if or and... 09-19-2014, 06:02 AM
JOHN H. DAVIS Re: need help with if or and... 09-19-2014, 08:51 AM
erickmcburger Re: need help with if or and... 09-23-2014, 08:16 AM
  1. #1
    Registered User
    Join Date
    09-19-2014
    Location
    goa,india
    MS-Off Ver
    MS excel 2007
    Posts
    24

    need help with if or and mid statement

    i have some strings in coloumn B2...it is all constant or all cells till the 17th character of the string after which there are codes like FI,WM,MM,CO..etc
    i want to check with these codes and give a common code eg
    if it is FI or CO then show FICO if it is MM or PUR or show MM etc i have used this code

      Dim MODULE As String, i As Integer
        
        i = 2
        For i = 2 To 500
       
    If Mid(B2, 18, 2) = "FI" Or Mid(B2, 18, 2) = "CO" Or Mid(B2, 18, 2) = "IM" Then
            MODULE = "FICO"
     ElseIf Mid(B2, 18, 2) = "MD" Or Mid(B2, 18, 3) = "MM:" Or Mid(B2, 18, 3) = "PUR" Then
              MODULE = "MM"
     ElseIf Mid(B2, 18, 2) = "QM" Or Mid(B2, 18, 2) = "PP" Or Mid(B2, 18, 2) = "PM" Or Mid(B2, 18, 2) = "PL" Or Mid(B2, 18, 2) = "BM" Then
               MODULE = "PP"
     ElseIf Mid(B2, 18, 2) = "SD" Then
             MODULE = "SD"
     ElseIf Mid(B2, 18, 2) = "SR" Then
               MODULE = "SRM"
     ElseIf Mid(B2, 18, 2) = "" Then
               MODULE = ""
     ElseIf Mid(B2, 18, 3) = "MM," Or Mid(B2, 18, 2) = "WM" Then
              MODULE = "WM"
     Else
              MODULE = "S&A"
               End If
               Cells(i, 1).Value = MODULE
               
    Next i
    but am getting only S&A

    it mayb a syntax error plz help
    Last edited by erickmcburger; 09-19-2014 at 11:30 PM. Reason: code change

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. compile error expected line number statement end statement
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2014, 10:12 AM
  2. VBA Compile Error : line number or label or statement or end of statement
    By excellearner121 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2013, 06:41 PM
  3. Replies: 4
    Last Post: 06-01-2012, 10:05 AM
  4. Replies: 4
    Last Post: 05-16-2012, 05:33 PM
  5. [SOLVED] Utilize a Select Case Statement in Target Intersect Statement
    By max57 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2009, 08:55 PM

Tags for this Thread

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