Adicionado em: | 07/10/2011 |
Modificado em: | 07/10/2011 |
Tamanho: | Vazio |
Downloads: | 875 |
Saberexcel - o site das macros
Esse procedimento do Aplicativo Microsoft Excel VBA, inserido na folha de planilha e sensizilizado pelo Evento SelectionChange, ao selecionar copia determinados números com caracteres inválidos para datas, e os transforma em datas válidas, com barras.
'------------'
15%07&2012 - será transformado em 15/07/2012
17(07*2012 - será transformado em 15/07/2012
19.12.2012 - será transformado em 19/12/2012
25$07#2012 - será transformado em 25/07/2012
18!08*2012 - será transformado em 18/08/2012
26"12£2012 - será transformado em 26/12/2012
31%12§2012 - será transformado em 31/12/2012
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Saber1.[A1].Value = ActiveCell.Offset(0, -2).Value
Data_Formato_dia_mes_ano
End Sub
'transformando um data formato texto (07.03.2012) no formato (07/03/2012)
Sub Data_Formato_dia_mes_ano()
Dim Ano As Integer, Mes As Integer, dia As Integer
Ano = Right(Range("A1"), 4)
Mes = Mid(Range("A1"), 4, 2)
dia = Left(Range("A1"), 2)
Range("A2") = DateSerial(Ano, Mes, dia)
End Sub
Escola Saberexcel VBA Estudos - Treinamentos, Macros, Fórmulas e funções http://www.microsoftexcel.com.br
Aprenda tudo sobre planilhas do Aplicativo Microsoft Excel VBA(Visual Basic Application), sozinho, com baixo custo, praticando com os produtos didáticos Saberexcel
Adicionado em: | 20/11/2010 |
Modificado em: | 20/11/2010 |
Tamanho: | Vazio |
Downloads: | 745 |
Procedimentos do Aplicativo MS Excel VBA, usando objetos textbox, no final da digitação dia, mes e ano, formata automaticamente o texto em uma outra textbox e também retorna o valor data para folha de planilha, no formato data(dd/mmm/aaaa).
1 - Userform
4 - Textbox
1 - CommandButton
Dim Dia As Integer
Dim Mês As Integer
Dim Ano As Integer
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub TextBox1_Change()
On Error Resume Next
If Len(TextBox1) = 2 Then
Dia = TextBox1
TextBox2.SetFocus
End If
End Sub
Private Sub TextBox2_Change()
On Error Resume Next
If Len(TextBox2) = 2 Then
Mês = TextBox2
TextBox3.SetFocus
End If
End Sub
Private Sub TextBox3_Change()
On Error Resume Next
If Len(TextBox3) = 4 Then
Ano = TextBox3
Call Validando_data
End If
End Sub
Private Sub Validando_data()
If Dia < 1 Or Dia > 31 Then
MsgBox "Dia Inválido"
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox1.SetFocus
Exit Sub
End If
If Mês < 1 Or Mês > 12 Then
MsgBox "Mês Inválido"
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox2.SetFocus
Exit Sub
End If
If Ano < 1990 Or Ano > 2011 Then
MsgBox "Mês Inválido"
TextBox3 = ""
TextBox4 = ""
TextBox3.SetFocus
Exit Sub
End If
TextBox4 = Format(Dia, "00") & "/" & Format(Mês, "00") _
& "/" & Format(Ano, "0000")
Sheets(1).Range("b5") = TextBox4
If IsError(Sheets(1).Range("B8")) Then
MsgBox "Data Inválida"
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
Sheets(1).Range("B5").Value = Format(Now, "DD/MM/YYYY")
TextBox1.SetFocus
End If
'Frame1.Caption = "Data: " & TextBox1.Value & "/" & TextBox2.Value & "/" & TextBox3.Value 'ou
Frame1.Caption = "Data Digitada: " & Format(Dia, "00") & "/" & Format(Mês, "00") _
& "/" & Format(Ano, "0000")
End Sub
Aprenda tudo sobre o Aplicativo MS Excel VBA com SaberExcel
Baixe o exemplo de planilha contendo os procedimentos acima
Publicidade:
Compre com Segurança, garantia e ótimos preços nas lojas submarino
Adicionado em: | 07/10/2011 |
Modificado em: | 07/10/2011 |
Tamanho: | Vazio |
Downloads: | 711 |
Saberexcel - o site das macros
Esse procedimento do Aplicativo Microsoft Excel VBA, inserido na folha de planilha e sensizilizado pelo Evento SelectionChange, ao selecionar copia determinados números com caracteres inválidos para datas, e os transforma em datas válidas, com barras.
'------------'
15%07&2012 - será transformado em 15/07/2012
17(07*2012 - será transformado em 15/07/2012
19.12.2012 - será transformado em 19/12/2012
25$07#2012 - será transformado em 25/07/2012
18!08*2012 - será transformado em 18/08/2012
26"12£2012 - será transformado em 26/12/2012
31%12§2012 - será transformado em 31/12/2012
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Saber1.[A1].Value = ActiveCell.Offset(0, -2).Value
Data_Formato_dia_mes_ano
End Sub
'transformando um data formato texto (07.03.2012) no formato (07/03/2012)
Sub Data_Formato_dia_mes_ano()
Dim Ano As Integer, Mes As Integer, dia As Integer
Ano = Right(Range("A1"), 4)
Mes = Mid(Range("A1"), 4, 2)
dia = Left(Range("A1"), 2)
Range("A2") = DateSerial(Ano, Mes, dia)
End Sub
Escola Saberexcel VBA Estudos - Treinamentos, Macros, Fórmulas e funções http://www.microsoftexcel.com.br
Aprenda tudo sobre planilhas do Aplicativo Microsoft Excel VBA(Visual Basic Application), sozinho, com baixo custo, praticando com os produtos didáticos Saberexcel
Adicionado em: | 13/04/2011 |
Modificado em: | 13/04/2011 |
Tamanho: | Vazio |
Downloads: | 681 |
Saberexcel - o site de quem precisa aprender Micrososft Excel VBA
Esse procedimento do Aplicativo Microsoft Excel VBA(Visual Basic Application), formata uma data em célula com auxílio de um objeto CommandButton.
.Value = Left(UCase(MonthName(Month(Date) - 1)), 4) & " " & Year(Date) 'quatro letras 'MARÇ'
.Value = UCase(MonthName(Month(Date) - 1)) & " " & Year(Date)
.Value = UCase(MonthName(Month(Date) - 1, True)) & " " & Year(Date)
.Value = DateSerial(Year(Date), Month(Date), -1)
Private Sub CommandButton1_Click()
If Day(Date) = 11 Then Rows("9").Insert xlShiftDown: Range("G9").Value = Month(Date)
ActiveCell.Value = Application.WorksheetFunction.Proper(ActiveCell.Value)
With Range("G9") '.
With .Font
.Bold = True ' teste negrito
.Name = "Arial"
.Size = 18
End With
'PODERÁ USAR UMA DAS FORMATAÇÕES ABAIXO
'.Value = DateSerial(Year(Date), Month(Date), -1)
'.Value = UCase(MonthName(Month(Date) - 1, True)) & " " & Year(Date)
'.Value = UCase(MonthName(Month(Date) - 1)) & " " & Year(Date)
.Value = Left(UCase(MonthName(Month(Date) - 1)), 4) & " " & Year(Date) 'quatro letras 'MARÇ'
.NumberFormat = "mmm - yyyy"
End With
End Sub
Aprenda tudo sobre planilhas do Aplicativo Microsoft Excel VBA(Visual Basic Application), sozinho, com baixo custo, praticando com os produtos didáticos Saberexcel
Adicionado em: | 24/01/2011 |
Modificado em: | 24/01/2011 |
Tamanho: | Vazio |
Downloads: | 643 |
Saberexcel - O site das macros
Essa macro do Aplicativo Microsoft Excel VBA(Visual Basic Application), adiciona uma nova planilha e nesta nova planilha insere os dias da semana como também os números correspondentes aos dias da semana ex: 1, segunda...2, terça...
Sub Insere_nova_plan_dias_semana()
Dim vNumero As Integer
Dim vTerminando As String
'On Error Resume Next
'//linhas comentadas para você fazer o teste, sempre inserirá uma nova planilha com o mesmo nome.
'Application.DisplayAlerts = False
'Sheets(1).Select: Sheets("DIAS DA SEMANA").Delete
Sheets.Add
' ActiveSheet.Name = "DIAS DA SEMANA"
ActiveCell.FormulaR1C1 = "Segunda-Feira"
Selection.AutoFill Destination:=Range("A1:A7"), Type:=xlFillDefault
For vNumero = 1 To 7
ActiveSheet.Cells(vNumero, 2) = vNumero
Next vNumero
'observe que nesta linha de código neste local, após a seleção da última célula,
'a propriedade offset, desloca duas linhas abaixo na mesma coluna e insere a msg finalizando.
ActiveCell.Offset(vNumero + 2, 1).Value = "FIM -- DIAS DA SEMANA INSERIDOS"
vTerminando = "Processo inserir dias da semana concluido......!"
MsgBox vTerminando
End Sub
Aprenda tudo sobre o pAplicativo Microsoft Excel VBA (Visual Basic Application), sozinho,
com baixo custo, praticando com os produtos didáticos SaberExcel
Adquira já o Acesso Imediato
à Area de Membros
Aprenda Excel VBA com Simplicidade de
códigos e Eficácia, Escrevendo Menos e
Fazendo Mais.
'-------------------------------------'
Entrega Imediata:
+ 500 Video Aulas MS Excel VBA
+ 35.000 Planilhas Excel e VBA
+ Coleção 25.000 Macros MS Excel VBA
+ 141 Planilhas Instruções Loops
+ 341 Planilhas WorksheetFunctions(VBA)
+ 04 Módulos Como Fazer Excel VBA
+ Curso Completo MS Excel VBA
+ Planilhas Inteligentes
<script type="text/javascript"><!--
google_ad_client = "ca-pub-2317234650173689";
/* retangulo 336 x 280 */
google_ad_slot = "0315083363";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
Aprenda tudo sobre o Aplicativo Microsoft Excel VBA(Visual Basic Application), sozinho, com baixo custo, praticando com os produtos didáticos Saberexcel,
Sobre as WorksheetFunctions Funções de Planilhas que retornam valores do VBA