Propósito

✔ Programação GLOBAL® - Quaisquer soluções e/ou desenvolvimento de aplicações pessoais, ou da empresa, que não constem neste Blog devem ser tratados como consultoria freelance. Queiram contatar-nos: brazilsalesforceeffectiveness@gmail.com | ESTE BLOG NÃO SE RESPONSABILIZA POR QUAISQUER DANOS PROVENIENTES DO USO DOS CÓDIGOS AQUI POSTADOS EM APLICAÇÕES PESSOAIS OU DE TERCEIROS.

Mostrando postagens com marcador number. Mostrar todas as postagens
Mostrando postagens com marcador number. Mostrar todas as postagens

VBA Excel - Extraindo Dígitos - Extract Digits (Remove Alphabets) from Selected Range

Inline image 1
Código para extrair dígitos:

Function ExtractDigits (ByVal cell As String) As Object
        'This function will extract 1st continuous set of digits.
        Dim i As Long, flag As Long 

        flag = 0
        ExtractDigits = "" 

        For i = 1 To Len(cell)
            If Mid(cell, i, 1) >= "0" And _
               Mid(cell, i, 1) <= "9" Then
                flag = 1
                ExtractDigits = ExtractDigits & Mid(cell, i, 1)
                ExtractDigits = ExtractDigits * 1
            Else
                If flag = 1 Then Exit Function
            End If
        Next i
End Function

    Sub Extract_Digits()
        ' This module will extract digits from selected range of cells using above User-defined function.         Dim MyCell As Range
        Dim tmpCol As Integer
        Dim flag As Boolean

        tmpCol = Selection.Column

        For Each MyCell In Selection.Cells
                MyCell.Value = ExtractDigits(MyCell.Value)
        Next

        MyCell = Nothing
    End Sub

Reference:
Tags: VBA, Excel, Number, Text, User Defined Function (UDF), VBA Macro


VBA Excel - Fechando uma planilha com Timer - Close an Excel workbook using a timer

Que tal fechar a sua planilha caso esta fique aberta por tempo demais?

Private Sub Workbook_Open()
    Let CloseAs = CDbl(Now + 5 / 86400)
    SetClosingTime
End Sub

Coloque o código abaixo num novo módulo:

Public CloseAs      As Double
Sub SetClosingTime()
    Application.OnTime CloseAs, "CloseWorkbook", , True
End Sub
Sub CloseWorkbook()
    With ThisWorkbook
        .Save
        .Close
    End With

'   Remove the line below to close the application
'   Application.Quit
End Sub

Referências
Tags: VBA, Word, number, sequencial, número



Word VBA - Como acrescentar um número seqüencial a um documento do MS Word - Adding a serial number to a Word document



Esta dica mostra como adicionar um número de série para um documento do MS Word usando o VBA. 

O número é atualizado sempre que o arquivo é aberto ...

Private Sub Document_Open()

  Set myCell = ThisDocument.Tables(1).Cell(Row:=1, Column:=1)

  Let nSerial = Left(myCell.Range.Text, Len (myCell.Range.Text) - 2)

  If nSerial = "" Then nSerial = 0
  ThisDocument.Tables (1).Cell (Row:=1, Column:=1).Range = nSerial + 1

  ThisDocument.Save

End Sub



Referências
Tags: VBA, Word, number, sequencial, número



diHITT - Notícias