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.

.: Vitrine

Carregando artigos...

Views

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

VBA Excel | Extraindo a Data de uma Célula com Data e Horário - Remove Date from Date and Time

VBA Excel | Extraindo a Data de uma Célula com Data e Horário - Remove Date from Date and Time

Extrai somente a Data de um Célula com Data e Horário.

Sub ExtractOnlyDate()

Dim Rng As Range

For Each Rng In Selection

If IsDate (Rng) = True Then

Let Rng.Value = Rng.Value - VBA.Fix (Rng.Value)

End If

Let NextSelection.NumberFormat = "hh:mm:ss am/pm"

End Sub


Veja outros códigos:

VBA Excel | Extraindo a Data de uma Célula com Data e Horário - Remove Date from Date and Time VBA Excel | Converta Tudo para Maiúscula - Convert to Upper CaseVBA Excel | Contando Palavras na Planilha - Word Count from Entire Worksheet VBA Excel | Removendo Decimais dos Números - Remove Decimals from Numbers

VBA Excel |  Multiplique todos os Valores por um Número - Multiply all the Values by a Number VBA Excel | Calculando a Raiz Cúbica - Calculate the Cube Root

VBA Excel | Adicionando Letras de A até Z - Add A-Z Alphabets in a Range VBA Excel | Convertendo Numerais Romanos em Arábicos - Convert Roman Numbers into Arabic Numbers

VBA Excel | Converta todos os Números Negativos em Positivos - Remove Negative Signs VBA Excel | Preencha com zeros as Células em Branco - Replace Blank Cells with Zeros


Conheça também:

VBA Excel | Código VBA de Pesquisa no Google - VBA Code to Search on Google

VBA Excel | Inserir várias Planilhas - Insert Multiple Worksheets

VBA Excel | Redimensione todos os Gráficos numa Planilha - Resize All Charts in a Worksheet

VBA Excel | Desproteger Planilha - Un-Protect Worksheet

VBA Excel | Proteger Planilha - Protect Worksheet

VBA Excel | Proteja todas as Planilhas Instantaneamente - Protect all Worksheets Instantly

VBA Excel | Excluir tudo, exceto a planilha ativa - Delete all but the Active Worksheet

VBA Excel | Ocultar tudo, exceto a planilha ativa - Hide all but the Active Worksheet

VBA Excel | Realçar Valores Únicos - Highlight Unique Values

VBA Excel | Realçar Células Com Comentários - Highlight Cells with Comments

VBA Excel | Faz Backup da Aba de trabalho Atual - Create a Backup of a Current Workbook

VBA Excel | Salve cada Planilha como um único PDF - Save Each Worksheet as a Single PDF

VBA Excel | Excluir todas as Planilhas em Branco - Delete all Blank Worksheets


Leia também:

eBook: Série DONUT PROJECT 2015: Projetos e Códigos de Visual Basic for Applications - Autor: André Luiz Bernardes  eBook: Série Top 10 Funções: Top 10 Funções VBA para o Microsoft Excel - Autor: André Luiz Bernardes

eBook: Série Funções Poderosas: 13 Funções Poderosas no MS Excel - Autor: André Luiz Bernardes  eBook: Série Visual Basic For Application: Criando Logs de acesso: Dicas e Códigos de Visual Basic for Applications - Autor: André Luiz Bernardes

eBook: Série VBA Tips: Rastrei seus Dashboards, Scorecards, Reports, Relatórios, Planilhas e Aplicações - Dicas e Códigos - Autor: André Luiz Bernardes  eBook: Série Data Science: Big Data, Como? - Autor: André Luiz Bernardes

eBook: Série Smarter Analytic: 5 Previsões de Big Data - Autor: André Luiz Bernardes


Conheça também:

DONUT PROJECT 2021 - VBA Function:  Como Rastrear o Google Maps (Coordenadas Geográficas) no VBA Excel?

DONUT PROJECT 2021 - VBA Function:  Crie Acrônimos a partir de Strings de Texto

DONUT PROJECT 2021 - VBA Function:  Convertendo uma Matrix num Vetor - Convert Matrix to a Vector

DONUT PROJECT 2021 - VBA Function:  Como tornar o Formulário Transparente no MS Excel?

DONUT PROJECT 2021 - VBA Function:  Faça Buscas no Google a Partir da Célula do MS Excel - Search Google From a Cell

DONUT PROJECT 2021 - VBA Function:  Decompondo um Nome nas Dimensões de uma Matriz

DONUT PROJECT 2021 - VBA Function: Extraindo o Último Sobrenome de um Nome Completo ou a Última Palavra de uma Frase

DONUT PROJECT 2021 - VBA Function:  Extraindo o Segundo Nome de um Nome Completo ou a Segunda Palavra de uma Frase

DONUT PROJECT 2021 - VBA Function: Extraindo o Primeiro Nome ou  a Primeira Palavra de uma Frase

Série Piece of Cake

Séries Donut


Comente e compartilhe este artigo!


brazilsalesforceeffectiveness@gmail.com

Excel Tips - Funções de Data e Tempo - Date and time functions

Inline image 1

Para utilizarmos bem as funções do MS Excel precisamos ao menos saber que existem e conhecermos onde as podemos aplicar.

O que segue são algumas destas que podemos utilizar extensivamente, agora com um pouco mais de conhecimento.

Tenham em mente que elas estão expressas em inglês, escolhi assim para que pudéssemos ter proveito delas tanto funcionalmente no MS Excel quanto na programação VBA. Sei que na maioria das empresas a instalação está em português, o que pessoalmente acho péssimo, nestes casos poderá procurar pela referência de como escrevê-la em Português.

Ahh e não reclamem, aproveitem para usar o Google Translate se precisarem.

Funções de Data e Tempo

DATE
Returns the serial number of a particular date

DATEVALUE
Converts a date in the form of text to a serial number

DAY
Converts a serial number to a day of the month

DAYS360
Calculates the number of days between two dates based on a 360-day year

EDATE
Returns the serial number of the date that is the indicated number of months before or after the start date

EOMONTH
Returns the serial number of the last day of the month before or after a specified number of months

HOUR
Converts a serial number to an hour

MINUTE
Converts a serial number to a minute

MONTH
Converts a serial number to a month

NETWORKDAYS
Returns the number of whole workdays between two dates

NOW
Returns the serial number of the current date and time

SECOND
Converts a serial number to a second

TIME
Returns the serial number of a particular time

TIMEVALUE
Converts a time in the form of text to a serial number

TODAY
Returns the serial number of today's date

WEEKDAY
Converts a serial number to a day of the week

WEEKNUM
Converts a serial number to a number representing where the week falls numerically with a year

WORKDAY
Returns the serial number of the date before or after a specified number of workdays

YEAR
Converts a serial number to a year

YEARFRAC
Returns the year fraction representing the number of whole days between start_date and end_date



Tags: Function, Excel, Tips, functions, Date, Time




VBA Excel - Inserindo o caracter de barra ao formatar as Datas


A funcionalidade abaixo serve para deixar-nos mais à vontade ao inserir datas no MS Excel. 

Esta funcionalidade insere barras "/" para separar dd/mm/aa, ou seja, quando digitamos 05021972, será inserido uma formatação de barras na textbox, alterando o número digitado para 05/02/1972.


Public tx As String

Public k As Integer



Sub btnFormat_Click()
If Not IsDate(TextBox1) Then
  MsgBox "data inválida", vbInformation, "Saberexcel o site das macros"
  TextBox1.SetFocus
  
  Let TextBox1.SelStart = 10
  Let TextBox1.Text = ""

  TextBox1.SetFocus
Else
MsgBox "Data válida", vbInformation, "Saberexcel - o site das macros "
End If

End Sub


Sub TextBox1_KeyUp (ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)

Dim z As String
If TextBox1 = "" Then TextBox1 = "--/--/----": k = 0: tx = "": TextBox1.SelStart = 0: Exit Sub
If KeyCode = 8 Then
If k <= 1 Then TextBox1 = "--/--/----": TextBox1.SelStart = 0: k = 0: tx = "": Exit Sub
     
     k = k - 1
    tx = Left(tx, k)
    z = Right("--/--/----", 10 - k)
   If Len(tx) = 3 Then tx = Left(tx, 2): k = 2: z = "/--/----"
   
   If Len(tx) = 6 Then tx = Left(tx, 5): k = 5: z = "/----"
      TextBox1 = tx & z
      TextBox1.SelStart = k
   Exit Sub
   End If
   
   If k >= 10 Then TextBox1 = Left(TextBox1, 10): Exit Sub
      k = k + 1
      tx = tx & Mid(TextBox1, k, 1)
      z = Right("--/--/----", 10 - Len(tx))
   
   If Len(tx) = 6 Then tx = Left(tx, 5) & "/" & Right(tx, 1): z = "-": k = k + 1
   If Len(tx) = 5 Then tx = tx & "/": z = "----": k = k + 1
   If Len(tx) = 3 Then tx = Left(tx, 2) & "/" & Right(tx, 1): z = "-/----": k = k + 1
   If Len(tx) = 2 Then tx = tx & "/": z = "--/----": k = k + 1
      TextBox1 = tx & z
      TextBox1.SelStart = k
End Sub

Pode tentar essas soluções:

DATE(RIGHT(A1,4), LEFT(A1),MID(A1,2,2))

=DATE(VALUE(RIGHT(A2,4)), VALUE(LEFT(A2,1)), VALUE(MID(A2,2,2)))

dDate = Dateserial(Mid(strDateTime, 1, 2), _
Mid(strDateTime, 5, 2), _
Mid(strDateTime, 3, 2))

Estude também a opção abaixo:


Sub Worksheet_Change (ByVal Target As Range)
    Select Case Target.Column
    Case 3, 5  ' columns C & E are 3rd & 5th columns
        Let TypedVal = Application.WorksheetFunction. _

            Text(Target.Value, "000000")
        Let NewValue = Left(TypedVal, 2) & "/" & _
            Mid(TypedVal, 3, 2) & "/" & _
            Right(TypedVal, 2)
    Case 4, 6 ' Columns D & F are time columns
        Let TypedVal = Application.WorksheetFunction. _
            Text(Target.Value, "0000")
        Let NewValue = Left(TypedVal, 2) & ":" & _
            Right(TypedVal, 2)
    End Select
    If NewValue > 0 Then
        Application.EnableEvents = False
        Let Target.Value = NewValue
        Let Application.EnableEvents = True
    End If
End Sub


Reference::
Shane Devenshire, 

Tags: VBA, Excel, Barra, /, Date, format, slash

Inline image 1

diHITT - Notícias