Vídeo recomendado
https://youtu.be/diWPPPhW-9E

urgente!!!

Dúvidas gerais sobre Excel
camilaposser
Acabou de chegar
Acabou de chegar
Mensagens: 7
Registrado em: Ter Out 23, 2012 3:59 pm

urgente!!!

Mensagem por camilaposser »

tenho esse codigo para mostrar dados cadastrados no listview, mas eu queria que ao dar 2 cliques no dado desejado os dados vao para o form de cadastro onde eu possa fazer alteraçoes e tals. ja tenha o form de cadastro (frm_grup), to precisando do codigo com urgencia!
Esse eh o meu codigo do frmpesquisa

Private Const NomePlanilha As String = "grupos"
Private Const LinhaCabecalho As Integer = 1

Private Sub ComboBoxCampos_Change()
Me.TextBoxFiltro.SetFocus
End Sub




Private Sub ListView1_BeforeLabelEdit(Cancel As Integer)

End Sub

Private Sub UserForm_Initialize()

Call PreencheCampos
Me.ComboBoxCampos.ListIndex = 1
PreencherListView
Me.Label2.Caption = Format(ListView1.ListItems.Count, "00")
End Sub
Sub PreencherListView()
Dim lastRow As Long
Dim li As ListItem
Dim x As Long

' Adiciona as colunas
With ListView1
.ColumnHeaders.Clear
.Gridlines = True
.View = lvwReport
'.FullRowSelect
.ColumnHeaders.Add Text:="Código", Width:=30
.ColumnHeaders.Add Text:="Universidade", Width:=80
.ColumnHeaders.Add Text:="Linha", Width:=160
.ColumnHeaders.Add Text:="NomedoGrupo", Width:=120
.ColumnHeaders.Add Text:="LinhasdePesquisa", Width:=200
.ColumnHeaders.Add Text:="LiderdoGrupo", Width:=70
.ColumnHeaders.Add Text:="ViceLider", Width:=70
.ColumnHeaders.Add Text:="Região", Width:=45

' .Gridlines = True 'efeito grade
End With
'...................................................................
'limpar
ListView1.ListItems.Clear

lastRow = Plan1.Cells(Plan1.Cells.Rows.Count, "a").End(xlUp).Row

' Adiciona itens
For x = 2 To lastRow
Set li = ListView1.ListItems.Add(Text:=Format(Plan1.Cells(x, "a").Value, "00"))
li.ListSubItems.Add Text:=Plan1.Cells(x, "b").Value
li.ListSubItems.Add Text:=Plan1.Cells(x, "c").Value
li.ListSubItems.Add Text:=Plan1.Cells(x, "d").Value
li.ListSubItems.Add Text:=Plan1.Cells(x, "e").Value
li.ListSubItems.Add Text:=Plan1.Cells(x, "f").Value
li.ListSubItems.Add Text:=Plan1.Cells(x, "g").Value
li.ListSubItems.Add Text:=Plan1.Cells(x, "h").Value

Next
End Sub

Private Sub TextBoxFiltro_Change()
If Me.ComboBoxCampos.ListIndex = -1 Then
MsgBox "Selecione um Campo.", 64, "Treino Listview"
Me.TextBoxFiltro = ""
Exit Sub
End If

Dim strObjetoBuscar As String
Dim lngResultado As Long
'Dim lngColumna As Long, lngFila As Long
Dim a As Integer
Dim coluna
coluna = Me.ComboBoxCampos.ListIndex + 1
ListView1.ListItems.Clear
strObjetoBuscar = TextBoxFiltro.Value
If strObjetoBuscar = "" Then GoTo 99
strObjetoBuscar = LCase(strObjetoBuscar)
For a = 2 To 2010
lngResultado = InStr(1, Plan1.Cells(a, coluna), strObjetoBuscar, vbTextCompare)
If lngResultado > 0 Then
Set li = ListView1.ListItems.Add(Text:=Format(Plan1.Range("A" & a).Value, "00"))
li.ListSubItems.Add Text:=Plan1.Range("B" & a).Value
li.ListSubItems.Add Text:=Plan1.Range("C" & a).Value
li.ListSubItems.Add Text:=Plan1.Range("D" & a).Value
li.ListSubItems.Add Text:=Plan1.Range("E" & a).Value
li.ListSubItems.Add Text:=Plan1.Range("F" & a).Value
li.ListSubItems.Add Text:=Plan1.Range("G" & a).Value
li.ListSubItems.Add Text:=Plan1.Range("H" & a).Value

End If
Next a
99:
Me.Label2.Caption = Format(ListView1.ListItems.Count, "00")
End Sub
'######################################################
Private Sub PreencheCampos()
Dim ws As Worksheet
Dim coluna As Integer
Dim linha As Integer
Set ws = ThisWorkbook.Worksheets(NomePlanilha)
coluna = 1 'de 1 para 2
linha = LinhaCabecalho

With ws
While .Cells(linha, coluna).Value <> Empty
Me.ComboBoxCampos.AddItem .Cells(linha, coluna)
coluna = coluna + 1
If coluna = 13 Then Exit Sub
Wend
End With
End Sub

Private Sub PreencheCabecalho(ByRef Lista())
Dim ws As Worksheet
Dim coluna As Integer
Dim linha As Integer
Set ws = ThisWorkbook.Worksheets(NomePlanilha)
coluna = 1 'de 1 p 2
linha = LinhaCabecalho

With ws
While .Cells(linha, coluna).Value <> Empty
Lista(0, coluna - 1) = .Cells(linha, coluna) 'de -1 p -2
coluna = coluna + 1
Wend
End With
End Sub


Disable adblock

This site is supported by ads and donations.
If you see this text you are blocking our ads.
Please consider a Donation to support the site.


Avatar do usuário
webmaster
Administrador
Mensagens: 3114
Registrado em: Sex Jul 24, 2009 2:44 pm
Contato:

Re: urgente!!!

Mensagem por webmaster »

Camila,

Peço que atente às regras do fórum. O título, assim como a mensagem, devem refletir a descrição do problema. Escrever URGENTE, AJUDA ou coisas do tipo além de não ajudar, atrapalha a organização do fórum.

Se houver reincidência, vou baní-la, por tratar-se da segunda vez que isso acontece.

Att


Avatar do usuário
BaptistaCG
Colaborador
Colaborador
Mensagens: 96
Registrado em: Seg Jul 30, 2012 10:33 pm
Localização: Sorocaba/SP

Re: urgente!!!

Mensagem por BaptistaCG »

Ola,
Mesmo procedimento de sua outra mensagem, coloca aqui que tento adaptar um codigo que uso aqui.

Att.


Disable adblock

This site is supported by ads and donations.
If you see this text you are blocking our ads.
Please consider a Donation to support the site.


Responder