+ Reply to Thread
Results 1 to 4 of 4

Need vba to solve select criteria get SR no after # from desc and end with result if blank

Hybrid View

julielara Need vba to solve select... 01-09-2016, 05:13 AM
jaslake Re: Need vba to solve select... 01-09-2016, 04:10 PM
julielara Re: Need vba to solve select... 01-11-2016, 02:09 PM
jaslake Re: Need vba to solve select... 01-11-2016, 02:42 PM
  1. #1
    Forum Contributor
    Join Date
    11-25-2015
    Location
    bangalore
    MS-Off Ver
    2019
    Posts
    120

    Need vba to solve select criteria get SR no after # from desc and end with result if blank

    Dear experts

    I have month end data which contains multiple columns range A:G

    Criteria is: in B:B column value apart from CSV File & Process by others select rest of all then column E:E select only blanks & N/A# then in column D:D see some description part exist with long string which some values comes with number sign # after # there is digits values is SR NO should be retrieve from description and fill the constrain rows which are not found SR no in description for blank cells of E:E column ,fill result like "SR No Not found"

    Easy understand:
    B:B select all apart from CSV File & Process by others then
    E:E column select only Blank and n/A then
    D:D in description part contains # after some digits values is SR No copy to E:E on consistent rows
    G:G what are rows still blank in B:B towards G:G fill the text "SR No Not found"

    find the attachment
    Attached Files Attached Files
    Last edited by julielara; 01-09-2016 at 05:17 AM. Reason: attachment

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Need vba to solve select criteria get SR no after # from desc and end with result if b

    Hi Julielara

    This Code in the attached will work on your Sample Data (report dec) but there are many inconsistencies in the Data. It will probably need to be modified to accommodate any additional unknown inconsistencies.

    CTRL + x will fire the Code.

    Option Explicit
    
    Sub SR_Numbers()
       Dim ws           As Worksheet
       Dim Rng          As Range
       Dim Cel          As Range
       Dim LR           As Long
    
       Application.ScreenUpdating = False
       Set ws = Sheets("report dec")
       With ws
          If Not .AutoFilterMode Then
             .Rows("1:1").AutoFilter
          End If
          LR = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                           SearchDirection:=xlPrevious).Row
          .Range("A1:G" & LR).AutoFilter Field:=2, Criteria1:= _
                                         "<>CSV File", Operator:=xlAnd, Criteria2:="<>Processed by Others"
          .Range("A1:G" & LR).AutoFilter Field:=5, Criteria1:="=NA", _
                                         Operator:=xlOr, Criteria2:="="
          Set Rng = .Range(.Cells(2, "D"), .Cells(LR, "D")).SpecialCells(xlCellTypeVisible)
          For Each Cel In Rng
             On Error Resume Next
             Cel.Offset(0, 1) = Split(Cel.Value, "#")(1)
             On Error GoTo 0
    
             On Error Resume Next
             Cel.Offset(0, 1) = Split(Cel.Offset(0, 1).Value, "-")(0)
             On Error GoTo 0
    
             On Error Resume Next
             Cel.Offset(0, 1) = Split(Cel.Offset(0, 1).Value, " ")(1)
             On Error GoTo 0
    
             If InStr(Cel.Offset(0, 1).Text, "_") > 0 Then
                Cel.Offset(0, 1) = Split(Cel.Offset(0, 1).Value, "_")(0)
             End If
    
             If Cel.Offset(0, 1).Value = "" Then
                Cel.Offset(0, 3).Value = "SR No Not found"
             Else
                Cel.Offset(0, 1).Value = "# " & Cel.Offset(0, 1).Value
             End If
          Next Cel
          .AutoFilterMode = False
       End With
       Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files
    Last edited by jaslake; 01-10-2016 at 03:56 PM.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Contributor
    Join Date
    11-25-2015
    Location
    bangalore
    MS-Off Ver
    2019
    Posts
    120

    Re: Need vba to solve select criteria get SR no after # from desc and end with result if b

    Amazing Sir It works Piece of master work

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Need vba to solve select criteria get SR no after # from desc and end with result if b

    You're welcome...glad I could help.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 10-18-2013, 11:18 AM
  2. [SOLVED] formula help to get date from four cell through criteria, if not found result blank
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-01-2013, 04:56 AM
  3. Replies: 1
    Last Post: 10-27-2012, 02:54 AM
  4. Replies: 4
    Last Post: 12-27-2011, 04:26 PM
  5. Cell formula result unexpected when blank date criteria entered
    By TGP in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-06-2010, 07:59 AM
  6. Replies: 2
    Last Post: 03-11-2010, 07:58 PM
  7. Replies: 2
    Last Post: 03-07-2009, 11:44 PM
  8. Replies: 0
    Last Post: 04-13-2006, 07:25 AM

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