Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
Por andriessen
Posts
#73709
Boa tarde! Fiz uma Listview com um cadastro de moradores, sao 8 moradores por apto mas gostaria que onde tem no lugar do NOME tem um "#" nao seja carregado no listView

Alguem para ajudar?
Sub Carregar_Dados1()
'Tratamento de Erro
On Error GoTo Erro
'Planilha de trabalho
BuscaRapida.Select
'Define o ListView
With List1
'Paramentros do ListView
.Gridlines = True
.View = lvwReport
.FullRowSelect = True
.MultiSelect = True
'Cabeçalho
.ColumnHeaders.Add Text:="Nome", Width:=400, Alignment:=0
.ColumnHeaders.Add Text:="Apartamento", Width:=90, Alignment:=2
End With
'Variavel
Dim Linha1 As Double
Dim Lista1 As Object
'Linha inicial de dados
Linha1 = 4
'Limpa dados do ListView
List1.ListItems.Clear
'Determina a planilha de busca
With BuscaRapida
'Laço de repetição até encontrar vazio
While .Cells(Linha1, 2).Value <> Empty
'Carrega dados no ListView
With List1
If Cells(Linha1, 2) <> "" Then
Set Lista1 = List1.ListItems.Add(Text:=BuscaRapida.Cells(Linha1, 1).Value)
Lista1.ListSubItems.Add Text:=BuscaRapida.Cells(Linha1, 2).Value
Else
End If
'Else
End With
'Contilua o laço
Linha1 = Linha1 + 1
Wend
End With
'Limpa o ListView
Set Lista1 = Nothing
'Chama a contagem de registros
Call Contar1
'Sai do codigo
Exit Sub
Erro:
MsgBox "Erro!", vbCritical, "ERRO"
End Sub
#73710
Veja se ajuda.

If Cells(Linha1, 2) <> "" And Cells(Linha1, 2) <> "#" Then
#73713
Se você anexar uma cópia do seu arquivo Excel talvez ajude a entender o seu problema.
#73715
osvaldomp escreveu: 25 Out 2023 às 21:17 Se você anexar uma cópia do seu arquivo Excel talvez ajude a entender o seu problema.
Obrigado amigo, consegui resolver assim: Fiz uma macro e chamei ela no iniciar
Sub removerLinhasEmBranco()
Dim linhaAtual As Long
Dim ultimaLinha As Long

' Definir a última linha do ListView
ultimaLinha = List1.ListItems.Count

' Loop para remover as linhas em branco
For linhaAtual = ultimaLinha To 1 Step -1
If Len(List1.ListItems(linhaAtual).Text) = 0 Then
List1.ListItems.Remove linhaAtual
End If
Next linhaAtual

End Sub
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord