473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

I'd like to clear empty or blank rows in a listbox from my workbook. Can you help me?

Hello, I saw that you helped a guy that got the same problema than me. So I guess that you can help me too :) could you?

I have a code to populate data to listbox and filter an specifict item by textbox.
But when it populate all data, blank rows came together and I want to clear them, IDK how can I do this! :X

Here's my code...

Expand|Select|Wrap|Line Numbers
  1. Sub FILTRO_TEXTO()
  2. Application.ScreenUpdating = False
  3. Application.DisplayAlerts = False
  4. Dim Linha, linhalistbox As Integer
  5. Dim valor_celula As String
  6. linhalistbox = 1
  7. Linha = 2
  8. ListBox1.Clear
  9.  
  10. Sheets("Plan1").Select
  11. With Sheets("Plan1")
  12.  
  13.         While .Cells(Linha, 1).Value <> ""
  14.             valor_celula = .Cells(Linha, 1).Value <> ""
  15.             If UCase(Left(valor_celula, Len(TextBox1.Text))) = UCase(TextBox1.Text) Then
  16.             valor_celula = .Cells(Linha, 2).Value <> ""
  17.             If UCase(Left(valor_celula, Len(TextBox2.Text))) = UCase(TextBox2.Text) Then
  18.             valor_celula = .Cells(Linha, 3).Value <> ""
  19.             If UCase(Left(valor_celula, Len(TextBox3.Text))) = UCase(TextBox3.Text) Then
  20.             valor_celula = .Cells(Linha, 4).Value <> ""
  21.             If UCase(Left(valor_celula, Len(TextBox4.Text))) = UCase(TextBox4.Text) Then
  22.             valor_celula = .Cells(Linha, 5).Value <> ""
  23.             If UCase(Left(valor_celula, Len(TextBox5.Text))) = UCase(TextBox5.Text) Then
  24.  
  25.     Me.ListBox1.ColumnWidths = "40;80;300;200"
  26.     Me.ListBox1.ForeColor = RGB(0, 0, 102)
  27.  
  28.     With ListBox1
  29.  
  30.        .AddItem
  31.        .List(0, 0) = "Ticket"
  32.        .List(0, 1) = "Projeto"
  33.        .List(0, 2) = "Descrição"
  34.        .List(0, 3) = "Responsável"
  35.        .List(0, 4) = "Status"
  36.  
  37.         End With
  38.  
  39.           With ListBox1
  40.           .AddItem
  41.             .List(linhalistbox, 0) = Sheets("Plan1").Cells(Linha, 1) 'Ticket
  42.             .List(linhalistbox, 1) = Sheets("Plan1").Cells(Linha, 2) 'Projeto
  43.             .List(linhalistbox, 2) = Sheets("Plan1").Cells(Linha, 3) 'Descrição
  44.             .List(linhalistbox, 3) = Sheets("Plan1").Cells(Linha, 4) 'Responsável
  45.             .List(linhalistbox, 4) = Sheets("Plan1").Cells(Linha, 5) 'Status
  46.             End With
  47.             linhalistbox = linhalistbox + 1
  48.                 End If
  49.                     End If
  50.                         End If
  51.                             End If
  52.                                 End If
  53.  
  54.             Linha = Linha + 1
  55.             Wend
  56.  
  57.    End With
  58.  
  59. Application.ScreenUpdating = True
  60. Application.DisplayAlerts = True
  61.  
  62. End Sub
Jul 24 '18 #1
1 948
zmbd
5,501 Expert Mod 4TB
1) Link to the other thread so that we have some context
2) What have you tried already to fix this issue. We're happy to help; however, we don't wade thru tons of code - you have to have already done the basic troubleshooting.
Jul 24 '18 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Richard Yardley | last post by:
I have a mailing label report and would like to remove the space taken up by rows with no info (move the other rows up). I am a beginner using MS Access 2000 and would appreciate any help. ...
1
by: Tamturr | last post by:
Hello I know I saw the answer to this question here a while ago (when I didn't need the answer :) ) and I can't for the life of me find it, so I apologize. My problem is this: I want to copy a...
2
by: New Guy | last post by:
I've been trying to look this up in Help but I've had no luck because I don't know what to call it. (That's not phrased very well but I think you get what I mean.) I have a report that is...
3
by: Husam | last post by:
Hi EveryBody: I made project by Vb.Net which consist the following items: 1\ Textbox 2\Button 3\Listbox When you write any thing in the textbox and press the button any text written in...
2
by: Drew | last post by:
Hi all - I've written a simple script to read a .csv file and then write out rows to a new file only if the value in the 4th column is a 0. Here's the code: import csv reader =...
2
by: padawanlinuxero | last post by:
I have a program that goes to a MySQL table and puts all the data of the table in a CSV file, now I want to leave 6 rows in blank at top of the file when open in Excel, but I dont know how to do...
1
by: premMS143 | last post by:
Hi 1 & all, Using VB, How to remove blank rows in a Excel worksheet? For example, I'm having a Excel sheet containing 900 rows data, in which there are blank rows inserted in between. Manually...
2
by: mrubel99 | last post by:
I am trying to come up with a formula that from a value say in A1, will count itself and the number of blank rows, which will vary between values and change on a daily basis, to the next value in...
2
zmbd
by: zmbd | last post by:
So, I have the thread: Has Anyone Attempted a Report for a Class Attendance Log? I've managed to get the format... however, I decided that I would like to append enough rows so that that there...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.