+ Reply to Thread
Results 1 to 5 of 5

to find last number and missing number in series from various sheets

Hybrid View

  1. #1
    Registered User
    Join Date
    02-11-2016
    Location
    dubai
    MS-Off Ver
    msoffice 2010
    Posts
    75

    to find last number and missing number in series from various sheets

    Please help me in this

    i have the sample workbook, refer to the attached.
    .
    I need to get the report as attached in XL with sheet name “ReportRequired”.
    .
    Basically I have 4 sheets currently and I have named the branch name as 001 , 002 , 003, 004. Also will have more sheets as well.
    .
    Each sheet contains the similar column headers and
    We write the serial number in column C
    We write the other data’s is other fields. Specially, we write currency in column D
    On each dates we continue the serial number of the concern branches.
    .
    What we required is as a report
    Last serial number available each sheet.
    Missing number. If the currency is missed in column D, then that serial suppose to be missed.
    .
    Please refer to the excel and help me in VBA codes to execute the reports.
    .
    Thanks in Advance


    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: to find last number and missing number in series from various sheets

    Sub test()
    Dim sh As Worksheet, x As Long, my_sheet As String, my_string As String, mystring2 As String, last_entry As String
    For Each sh In Sheets
        If IsNumeric(sh.Name) Then
            my_sheet = Format(sh.Name, "000")
            
            last_entry = Sheets(sh.Name).Range("C" & Rows.Count).End(xlUp).Value
            lr = Sheets(sh.Name).Range("C" & Rows.Count).End(xlUp).Row
                For x = 2 To lr
                    If Sheets(sh.Name).Range("D" & x) = vbNullString Then
                        mystring = mystring & "| " & Sheets(sh.Name).Range("C" & x).Value
                    End If
                Next
                If Len(mystring) = 0 Then mystring2 = ""
                If Len(mystring) > 0 Then mystring2 = Right(mystring, Len(mystring) - 2)
            Sheets("ReportRequired").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(, 3) = Array(my_sheet, last_entry, mystring2)
            mystring = ""
        End If
    Next
    End Sub
    Kind regards
    Leo
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    02-11-2016
    Location
    dubai
    MS-Off Ver
    msoffice 2010
    Posts
    75

    Re: to find last number and missing number in series from various sheets

    DEAR LEO,

    Thanks for the code. My some of the sheet name carries alphabets as well. Code is not working if the sheet name carries alphabet.

    Thanks

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: to find last number and missing number in series from various sheets

    This takes all sheets except the ReportRequired

    Sub test()
    Dim sh As Worksheet, x As Long, my_sheet As String, my_string As String, mystring2 As String, last_entry As String
    For Each sh In Sheets
        If sh.Name <> "ReportRequired" Then
            If IsNumeric(sh.Name) Then
                my_sheet = Format(sh.Name, "000")
                Else
                my_sheet = sh.Name
            End If
            last_entry = Sheets(sh.Name).Range("C" & Rows.Count).End(xlUp).Value
            lr = Sheets(sh.Name).Range("C" & Rows.Count).End(xlUp).Row
                For x = 2 To lr
                    If Sheets(sh.Name).Range("D" & x) = vbNullString Then
                        mystring = mystring & "| " & Sheets(sh.Name).Range("C" & x).Value
                    End If
                Next
                If Len(mystring) = 0 Then mystring2 = ""
                If Len(mystring) > 0 Then mystring2 = Right(mystring, Len(mystring) - 2)
            Sheets("ReportRequired").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(, 3) = Array(my_sheet, last_entry, mystring2)
            mystring = ""
        End If
    Next
    End Sub
    Kind regards
    Leo

  5. #5
    Registered User
    Join Date
    02-11-2016
    Location
    dubai
    MS-Off Ver
    msoffice 2010
    Posts
    75

    Re: to find last number and missing number in series from various sheets

    Thanks Leo,
    Its perfectly working.

    Thanks a lot.

+ 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. [SOLVED] Find missing number and copy only missing number to another coloumn
    By vijaynadiad in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-20-2013, 02:01 PM
  2. [SOLVED] How to find n-th small missing number?
    By Guerolito in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-13-2013, 11:42 AM
  3. [SOLVED] Vb code To Find the missing triplets and complete the number series..?
    By sem in forum Excel Programming / VBA / Macros
    Replies: 43
    Last Post: 05-31-2012, 02:48 PM
  4. Calculating Missing Values in Number Series
    By mike.greene in forum Excel General
    Replies: 10
    Last Post: 03-08-2012, 09:02 PM
  5. How to find missing number from chart.
    By sunwordelite in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2009, 01:14 PM
  6. Find the missing number?
    By Djanvk in forum Excel General
    Replies: 3
    Last Post: 04-26-2006, 03:15 PM
  7. Find Missing Number?
    By Djanvk in forum Excel General
    Replies: 3
    Last Post: 04-17-2006, 05:55 PM

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