Home Excel - Downloads / Areas Restritas Excel VBA - Userforms e outros

Excel VBA - Userforms e outros

  • - Acesso Livre
  • Documentos

    Ordenar por : Nome | Data | Acessos [ Ascendente ]

    vba usf botao ativa desativa tecla numlock vba usf botao ativa desativa tecla numlock

    popular!
    Adicionado em: 29/11/2010
    Modificado em: 29/11/2010
    Tamanho: Vazio
    Downloads: 570

    Esse exemplo de Macros, Procedimentos, Função e Declaração do Aplicativo Microsoft Excel VBA, ativa e ou desativa o botão NumsLock, com auxílio de um Botão Toogle (Botão de Ativação), que retorna (True / False ) (Verdadeiro ou Falso)

    Function NumsLock() As Boolean
    NumsLock = GetKeyState(VK_NUMLOCK) And 1 = 1
    End Function


    Private Sub CommandButton1_Click()
    Unload UserForm1
    End Sub


    Private Sub ToggleButton1_Click()
    'declaração
    GetKeyboardState kbArray
    kbArray.kbByte(VK_NUMLOCK) = IIf(kbArray.kbByte(VK_NUMLOCK) = 1, 0, 1)
    SetKeyboardState kbArray

    ToggleButton1.Caption = IIf(NumsLock() = 0, "Desativado", "Ativado")
    Label1.Caption = IIf(NumsLock() = 0, "Desativado", "Ativado")
    Frame1.Caption = IIf(NumsLock() = 0, "Tecla NumLook [Desativada]", "Tecla NumsLock [Ativada]")

    If Label1.Caption = "Desativado" Then
    Label1.BackColor = &H80C0FF
    Frame1.ForeColor = &HFF&
    Else
    Label1.BackColor = &H80FF80
    Frame1.ForeColor = &H4000&
    End If
    End Sub

    Private Sub UserForm_Initialize()
    'ToggleButton1.Value = True
    ToggleButton1.Caption = IIf(NumsLock() = 0, "[Desativada]", "[Ativada]")
    Label1.Caption = IIf(NumsLock() = 0, "Desativado", "Ativado")
    End Sub

    Aprenda Aplicativo Microsoft Excel VBA - SaberExcel



    vba usf posicionamento formulario na planilha vba usf posicionamento formulario na planilha

    popular!
    Adicionado em: 29/11/2010
    Modificado em: 29/11/2010
    Tamanho: Vazio
    Downloads: 1100

    Saberexcel - o site das macros
    Essas macros e procedimentos do Aplicativo Microsoft Excel VBA, abre um determinado objeto Userform(Formulário) em diversos posições na folha de planilhas, com auxílio de objetos Options, voce poderá escolher o lugar para o posicionamento do Userform.

    EM UM MÓDULO COMUM INSIRA OS CÓDIGOS
    Sub Abrir_userform()
    If Sheets(1).ComboBox1.Text = "" Then
    MsgBox "Selecione uma das opções"
    Else

    Select Case Sheets(1).ComboBox1.Text
    Case "Centro"
    UserForm1.StartUpPosition = 2
    Case "Qualquer Lugar"
    UserForm1.StartUpPosition = 1
    End Select

    UserForm1.Show
    End If
    End Sub


    NA FOLHA [MÓDULO] DE CÓDIGO DO OBJETO USERFORM INSIRA OS PROCEDIMENTOS

    Dim X As Integer, Y As Integer

    Private Sub optCentro_Click()
    If optCentro.Value Then
    UserForm1.Left = X
    UserForm1.Top = Y
    End If
    End Sub

    Private Sub optDirAba_Click()
    If optDirAba.Value Then
    UserForm1.Left = ActiveWindow.Width - UserForm1.Width
    UserForm1.Top = ActiveWindow.Height - UserForm1.Height
    End If
    End Sub

    Private Sub optDirAci_Click()

    If optDirAci.Value Then
    UserForm1.Left = ActiveWindow.Width - UserForm1.Width
    UserForm1.Top = 0
    End If

    End Sub

    Private Sub optEsqAba_Click()
    If optEsqAba.Value Then
    UserForm1.Left = 0
    UserForm1.Top = ActiveWindow.Height - UserForm1.Height
    End If
    End Sub

    Private Sub optEsqAci_Click()
    If optEsqAci.Value Then
    UserForm1.Left = 0
    UserForm1.Top = 0
    End If
    End Sub

    Private Sub UserForm_Activate()
    X = UserForm1.Left
    Y = UserForm1.Top
    End Sub




    Aprenda tudo sobre o Aplicativo Microsoft Excel VBA - SaberExcel



    vba usf formulario fixo na folha de planilha vba usf formulario fixo na folha de planilha

    popular!
    Adicionado em: 29/11/2010
    Modificado em: 29/11/2010
    Tamanho: Vazio
    Downloads: 1274

    Saberexcel - Site das Macros
    Essas declarações e procedimentos do Aplicativo Microsoft Excel VBA, impede o usuário de mover o userform (formulário) pela folha de planilha, tornando-o estático, imóvel.


    Private Declare Function RemoveMenu _
    Lib "user32" ( _
    ByVal hMenu As Long, _
    ByVal nPosition As Long, _
    ByVal wFlags As Long) _
    As Long

    Private Declare Function FindWindowA _
    Lib "user32" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) _
    As Long
    Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, _
    ByVal bRevert As Long) As Long

    Private Const MF_BYPOSITION As Long = &H400

    Private Sub CommandButton1_Click()
    Unload Me
    End Sub

    Private Sub UserForm_Initialize()
    Dim lFrmHdl As Long, iCount As Integer
    lFrmHdl = FindWindowA(vbNullString, Me.Caption)
    If lFrmHdl <> 0 Then
    'MF_BYCOMMAND
    'Indicates that uPosition gives the identifier of the menu item.

    'If neither the MF_BYCOMMAND nor MF_BYPOSITION flag is specified,
    'the MF_BYCOMMAND flag is the default flag.

    'MF_BYPOSITION
    'Indicates that uPosition gives the zero-based relative position of the menu item.
    'ie 0,1,2,3 etc
    'Exit Sub
    'Typical Windows has 6 menus
    'Restore, Move, Size, Minimise, Maximize, Close
    'Even though a Userform displays 2 = Move & Close
    'By default Move is the Next item
    'so just loop twice
    For iCount = 0 To 1
    RemoveMenu GetSystemMenu(lFrmHdl, False), 0, MF_BYPOSITION
    Next iCount


    End If
    End Sub


    Aprenda tudo sobre o Aplicativo Microsoft Excel VBA - SaberExcel



    vba usf label formatando cores caption tamanho vba usf label formatando cores caption tamanho

    popular!
    Adicionado em: 29/11/2010
    Modificado em: 29/11/2010
    Tamanho: Vazio
    Downloads: 947

    Objeto label do Aplicativo microsoft Excel VBA,
    Saberexcel - o site das macros

    Objeto Controle Label
    Os controles de labels são principalmente usados para descrever outros controles em um UserForm. Um controle de labels não pode ser editado pelo usuário enquanto o UserForm está sendo executado. Use a propriedade de Legenda para estabelecer ou devolver o texto em um controle de labels. Outras propriedades freqüentemente usadas para formatar um controle de Label incluem a propriedade de Fonte e a propriedade ForeColor.
    Como usar propriedades com a afirmação para formatar um controle de labels

    Para usar O com a afirmação para modificar as propriedades de um controle de Etiqueta, siga esses passos: Inicie o excel e faça os passos seguintes
    Na barra de ferramentas , aponte para a Macro, clique no Editor Básico Visual.
    no botão de inserção de objetos do visual basic clique UserForm para inserir um UserForm no seu livro de exercícios.
    Acrescente ao userform um label (rótulo)
    Acrescente um controle de CommandButton ao UserForm.
    Clique duas vezes o controle de CommandButton para abrir a janela de Código do UserForm.
    Na janela de Código, digite(Copie e cole) o código seguinte do evento de Clique de CommandButton1
    :

    Private Sub CommandButton1_Click()

    With Label1
    ' atribuindo o texto ao objeto label
    .Caption = "Este é o exemplo do Label 1"
    ' determinando o tamanho automatico do label (do tamanho do texto) .
    .AutoSize = True
    .WordWrap = False
    ' atribuindo o tamanho a fonte, o tamanho e estilo da fonte como também a cor.
    .Font.Name = "Times New Roman"
    .Font.Size = 14
    .Font.Bold = True
    ' Atribuindo a cor da fonte (Azul)
    .ForeColor = RGB(0, 0, 255)
    End With

    End Sub



    Depois de inserido o procedimento execute o userform.
    Click no botão CommandButton.
    O texto "Isto é o Exemplo de Etiqueta 1"




    Aprenda tudo sobre Aplicativo Microsoft Excel VBA - com SaberExcel




    vba usf listboxes exemplos uteis vba usf listboxes exemplos uteis

    popular!
    Adicionado em: 29/11/2010
    Modificado em: 29/11/2010
    Tamanho: Vazio
    Downloads: 902

    Saberexcel - o site das macros
    Exemplo de procedimentos do Aplicativo Microsoft Excel VBA, contendo oito(8) exemplos de Listbox, muito bom para usarmos em nossos projetos e trabalhos do dia-a-dia. Espero que isso possam ajudá-los. Fiquem com Deus, E_Marcondes






    Imagem do exemplo da listbox 1


    Option Explicit

    Private Sub cmbOK_Click()

    If ListBox1.ListIndex = -1 Then
    MsgBox "Nenhuma lista valor selecionado!", vbCritical
    Exit Sub
    End If

    Cells(2, 1).Value = ListBox1.Value

    Unload Me
    End Sub

    Private Sub cmFechar_Click()
    Unload Me
    End Sub

    Private Sub UserForm_Initialize()
    Dim vaManad As Variant

    vaManad = Array("Janeiro", "Fevereiro", "Março", "Abril", _
    "Maio", "Junho", "Julho", "Agosto", _
    "Setembro", "Outubro", "Novembro", _
    "Dezembro")

    With ListBox1
    .Clear
    .List = vaManad
    .ListIndex = -1
    .TextAlign = fmTextAlignCenter
    End With

    End Sub


    '...............................'

    Abaixo Imagem e procedimentos do exemplo da Listbox2



    Option Explicit


    Private Sub cmbOK_Click()
    If ListBox2.ListIndex = -1 Then
    MsgBox "Nennhum valor da lista foi selecionado!", vbCritical, "Saberexcel - o site das macros"
    Exit Sub
    End If

    Cells(2, 3).Value = ListBox2.Value

    Unload Me
    End Sub


    Private Sub UserForm_Initialize()
    Dim vGrupos, iValores As Variant
    Dim stLista() As String
    Dim i As Integer

    vGrupos = VBA.Array("AA", "BB", "CC")
    iValores = VBA.Array("10", "20", "30")

    ReDim stLista(0 To UBound(vGrupos), 0 To 1)

    For i = 0 To UBound(vGrupos)
    stLista(i, 0) = vGrupos(i)
    stLista(i, 1) = iValores(i)
    Next i

    With ListBox2
    .Clear
    .BoundColumn = 2
    .ColumnCount = 2
    .List = stLista
    .ListIndex = -1
    End With
    End Sub

    Private Sub mdFechar_Click()
    Unload Me
    End Sub



    '...............................'

    Abaixo Imagem e procedimentos do exemplo da Listbox3



    Option Explicit

    Private Sub cmbOK_Click()
    Dim i As Integer
    Dim rnCell As Range

    Set rnCell = Sheets("ListBox3").Range("A1")

    If ListBox3.ListIndex = -1 Then
    MsgBox "Nenhum valor da lista foi selecionado!", vbCritical, "Saberexcel - o site das macros"
    Exit Sub
    End If

    For i = 0 To ListBox3.ListCount - 1
    If ListBox3.Selected(i) Then _
    rnCell.Offset(i, 0).Value = ListBox3.List(i)
    Next i

    Unload Me
    End Sub

    Private Sub cmdFechar_Click()
    Unload Me
    End Sub

    Private Sub UserForm_Initialize()
    Dim vLista, iValores As Variant
    Dim stLista() As String
    Dim i As Integer

    vLista = VBA.Array("AA", "BB", "CC")
    iValores = VBA.Array("10", "20", "30")

    ReDim stLista(0 To UBound(vLista), 0 To 1)

    For i = 0 To UBound(vLista)
    stLista(i, 0) = vLista(i)
    stLista(i, 1) = vaAndra(i)
    Next i

    With ListBox3
    .Clear
    .BoundColumn = 2
    .ColumnCount = 2
    .List = stLista
    .ListIndex = -1
    .MultiSelect = fmMultiSelectMulti
    .TextAlign = fmTextAlignCenter
    End With

    End Sub





    '...............................'
    Abaixo Imagem e procedimentos do exemplo da Listbox4


    Option Explicit

    Private Sub cmbOK_Click()
    Dim i As Integer
    Dim rnCell As Range

    Set rnCell = Sheets("ListBox4").Range("A1")

    If ListBox2.ListIndex = -1 Then
    MsgBox "Insira o valor na lista!", vbCritical
    Exit Sub
    End If

    rnCell.Value = ListBox2.Value

    Unload Me
    End Sub

    Private Sub ListBox1_Click()
    Dim vaJan, vaFev, VaMar, vaAbril As Variant

    vaJan = VBA.Array("1", "2", "3")
    vaFev = VBA.Array("10", "20", "30")
    VaMar = VBA.Array("100", "200", "300")
    vaAbril = VBA.Array("1000", "2000", "3000")

    Select Case ListBox1.Value
    Case "Janueiro"
    ListBox2.List = vaJan
    Case "Fevereiro"
    ListBox2.List = vaFev
    Case "Março"
    ListBox2.List = VaMar
    Case "Abril"
    ListBox2.List = vaAbril
    End Select

    End Sub

    Private Sub UserForm_Initialize()
    Dim vaLista1 As Variant

    vaLista1 = VBA.Array("Janeiro", "Fevereiro", "Março", "Abril")

    With ListBox1
    .Clear
    .List = vaLista1
    End With
    End Sub

    Private Sub cmdFechar_Click()
    Unload Me
    End Sub


    '...............................'
    Abaixo Imagem e procedimentos do exemplo da Listbox5

    Option Explicit


    Private Sub cmbOK_Click()
    Dim i, j As Integer
    Dim rnCell As Range

    Set rnCell = Sheets("ListBox5").Range("A1")

    If ListBox5.ListIndex = -1 Then
    MsgBox "Nenhum valor foi seleciona nesta lista!", vbCritical, "Saberexcel - o site das macros"
    Exit Sub
    End If

    j = 0
    For i = 0 To ListBox5.ListCount - 1
    If ListBox5.Selected(i) Then
    j = j + 1
    rnCell.Offset(j, 0).Value = ListBox5.List(i, 0)
    rnCell.Offset(j, 1).Value = ListBox5.List(i, 1)
    End If
    Next i

    Unload Me
    End Sub

    Private Sub cmdFechar_Click()
    Unload Me
    End Sub

    Private Sub UserForm_Initialize()
    Dim iValores, vaAndra As Variant
    Dim stLista() As String
    Dim i As Integer

    iValores = VBA.Array("AA", "BB", "CC")
    vaAndra = VBA.Array("10", "20", "30")

    ReDim stLista(0 To UBound(iValores), 0 To 1)

    For i = 0 To UBound(iValores)
    stLista(i, 0) = iValores(i)
    stLista(i, 1) = vaAndra(i)
    Next i

    With ListBox5
    .Clear
    .BoundColumn = 2
    .ColumnCount = 2
    .List = stLista
    .ListIndex = -1
    .MultiSelect = fmMultiSelectMulti
    End With

    End Sub

    Private Sub cmdFechar_Click()
    Unload Me
    End Sub


    '...............................'
    Abaixo Imagem e procedimentos do exemplo da Listbox6


    Option Explicit

    Private Sub UserForm_Initialize()
    Dim vCelula, vIntervalo As Range

    Set vIntervalo = Worksheets("Listbox6").Range("B2:G2")

    For Each vCelula In vIntervalo
    ListBox6.AddItem vCelula.Value
    Next vCelula

    End Sub

    Private Sub cmbOK_Click()
    Unload Me
    End Sub



    '...............................'
    Abaixo Imagem e procedimentos do exemplo da Listbox7



    Private Sub UserForm_Initialize()
    Dim rnLista, rnCell As Range
    Dim wkData As Worksheet

    Set wkData = ThisWorkbook.Sheets("ListBox7")

    Set rnLista = Union(wkData.Range("A2:A4"), wkData.Range("E2:E4"))

    For Each rnCell In rnLista
    ListBox7.AddItem rnCell.Value
    Next rnCell

    End Sub

    Private Sub cmbOK_Click()
    Unload Me
    End Sub


    '...............................'
    Abaixo Imagem e procedimentos do exemplo da Listbox8



    Option Explicit


    Private Sub cmbOK_Click()
    Dim iDados, vLista As Integer
    Dim i, j As Integer
    Dim vTemp As String

    iDados = 0
    vLista = ListBox8.ListCount - 1

    For i = iDados To vLista - 1
    For j = i + 1 To vLista
    If ListBox8.List(i) > ListBox8.List(j) Then
    vTemp = ListBox8.List(j)
    ListBox8.List(j) = ListBox8.List(i)
    ListBox8.List(i) = vTemp
    End If
    Next j
    Next i

    End Sub

    Private Sub cmdFechar_Click()
    Unload Me
    End Sub

    Private Sub UserForm_Initialize()
    Dim vMeses As Variant
    vMeses = Array("Jan", "Fev", "Mar", "Abr", _
    "Mai", "Jun", "Jul", "Ago", _
    "Set", "Out", "Nov", _
    "Dez")

    With ListBox8
    .Clear
    .List = vMeses
    .ListIndex = -1
    End With

    End Sub



    Aprenda tudo sobre o Aplicativo Microsoft Excel VBA - com SaberExcel



    Página 9 de 10

    PROMOÇÃO DIDÁTICOS SABEREXCEL



    Adquira já o Acesso Imediato
    à Area de Membros

    Compra Grantida --- Entrega Imediata

    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


    Pesquisa Google SaberExcel

    Publicidade Google

    <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>

    Publicidade

    RSFirewallProtected


    Google Associados

    Depoimentos

    Adicione Saberexcel Favoritos

     
     

    Aprenda tudo sobre o Aplicativo Microsoft Excel VBA

    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