![]() |
Skipping blank cells in a column...
I have a column where some data is dumped. Sometimes there is a blank cell in
a column. I want to add the values to the listbox from only those cells where there is a data. If there is no data i need to skip the cell. I am using the following code...which works fine if there are no blanks in between or start ....but it doesn't work fine for where there are blank in between or start Suggestions will be highly appreciated. Set TestSheet = ThisWorkbook.Sheets("Test") TopicCount = Application.WorksheetFunction.CountA(TestSheet.Ran ge("3:3")) For Col = 2 To TopicCount + 1 lstbox1.AddItem TestSheet.Cells(3, Col) Next Col lstbox1.ListIndex = 0 -- Ajit |
Skipping blank cells in a column...
Dim rng as Range, Testsheet as Worksheet
Set TestSheet = ThisWorkbook.Sheets("Test") With TestSheet set rng = .Range(.Cells(3,1),.Cells(3,256).End(xltoLeft)) End With For each cell in rng if not isempty(cell) then lstbox1.AddItem cell.Value Next lstbox1.ListIndex = 0 -- Regards, Tom Ogilvy "Ajit" wrote in message ... I have a column where some data is dumped. Sometimes there is a blank cell in a column. I want to add the values to the listbox from only those cells where there is a data. If there is no data i need to skip the cell. I am using the following code...which works fine if there are no blanks in between or start ....but it doesn't work fine for where there are blank in between or start Suggestions will be highly appreciated. Set TestSheet = ThisWorkbook.Sheets("Test") TopicCount = Application.WorksheetFunction.CountA(TestSheet.Ran ge("3:3")) For Col = 2 To TopicCount + 1 lstbox1.AddItem TestSheet.Cells(3, Col) Next Col lstbox1.ListIndex = 0 -- Ajit |
All times are GMT +1. The time now is 11:21 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com