Notice: WC_Cart::get_cart_url is deprecated since version 2.5! Use wc_get_cart_url instead. in /home/swatipaliwal/public_html/excelcrazy.com/wp-includes/functions.php on line 3839
Excel Crazy

Find nth word from text string-EXCEL/VBA

Problem Statement

Now this time we have an interesting challenge, what we want to extract is, Nth text from a statement. For this I have created one user defined function. you have to pass two arguments, one text which you are looking for and second statement.

For Example:

In the below screenshot worksheets are not sorted in any order.

After running macro, they will be arranged in systematic manner

SOLUTION

Sub Arrange_Sheets()
Dim Sort_Descending As Boolean
Dim count_Sheets As Integer
Dim i As Integer
Dim j As Integer
No_of_Sheets = Sheets.Count

'Change Flag As appropriate
Sort_Descending = False
For i = 1 To No_of_Sheets
        For j = 1 To i
               If Sort_Descending = True Then
                If UCase(Sheets(i).Name) > UCase(Sheets(j).Name) Then
                                Sheets(i).Move Before:=Sheets(j)
                End If
           End If
          If Sort_Mode_Descending = False Then
            If UCase(Sheets(i).Name) < UCase(Sheets(j).Name) Then
                        Sheets(i).Move Before:=Sheets(j)
            End If
          End If
 
        Next j
            Next i
End Sub

STEPS TO PERFORM

1. Go to developer Tab else Press Alt + F11
2.Click on Visual Basic icon
3.Go to Insert click on Module
4.Paste below code in standard module

December 31, 2017

0 responses on "Find nth word from text string-EXCEL/VBA"

Leave a Message

Your email address will not be published. Required fields are marked *

top
 

© LOKESH PALIWAL 1987 - 2017

Reporting Solutions | Data Consulting | Analytics Training