Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Microsoft Office и VBA программирование > Microsoft Office Excel
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 27.05.2009, 15:06   #1
london735
Пользователь
 
Регистрация: 20.06.2008
Сообщений: 45
По умолчанию Condensing a Data Set

Hello!
I want to ask if there is a way to simply extract non-empty rows from a data set consisting of many rows filled with zeroes and some which are filled with the non-zero values. By “simply” I mean without using any macros. Any help or suggestions are highly appreciated.

PS: I have attached the workbook with example of the sheet with such data set (CLEAN tab shows the desired result of this operation):
Вложения
Тип файла: zip EXAMPLE DATA SET.zip (2.4 Кб, 12 просмотров)
london735 вне форума Ответить с цитированием
Старый 27.05.2009, 15:31   #2
EducatedFool
Программист VBA
СуперМодератор
 
Аватар для EducatedFool
 
Регистрация: 13.07.2008
Сообщений: 6,856
По умолчанию

Try to use the following macro:
Код:
Sub CopyRows()
    Application.ScreenUpdating = False
    Dim shSource As Worksheet: Set shSource = ActiveSheet
    Dim shDest As Worksheet: Set shDest = ThisWorkbook.Worksheets.Add
    shDest.Name = "New sheet " & Format(Now, "HH-NN-SS"): shDest.Tab.Color = vbGreen

    Dim cell As Range
    For Each cell In shSource.UsedRange.Columns(1).Cells
        If cell.Value <> 0 And Trim(cell.Value) <> "" Then
            cell.EntireRow.Copy shDest.Range("a" & Rows.Count).End(xlUp).Offset(1).EntireRow
        End If
    Next
    shDest.Rows(1).Delete
End Sub
Press the green button placed on RAW sheet in attached file:
Вложения
Тип файла: rar EXAMPLE DATA SET.rar (8.7 Кб, 10 просмотров)
EducatedFool вне форума Ответить с цитированием
Старый 27.05.2009, 16:53   #3
honeybeer
Новичок
Джуниор
 
Регистрация: 27.05.2009
Сообщений: 2
По умолчанию

Solution without macro.
Try to use "AutoFilter" (in main menu "Data"->"Filter"->"AutoFilter")
1) Insert row with headers for each data column above a data range

2) Select all data columns on "RAW" sheet

3) Use "AutoFilter" and condition "not equal 0"

No macros, no troubles
honeybeer вне форума Ответить с цитированием
Старый 27.05.2009, 19:56   #4
london735
Пользователь
 
Регистрация: 20.06.2008
Сообщений: 45
По умолчанию

thank you for your nice replies but I cannot use wither a macro or the traditional autofilter methods,....I need this to be done with formulas alone...is there a way to do this?
london735 вне форума Ответить с цитированием
Старый 06.06.2009, 23:37   #5
roplius
Пользователь
 
Регистрация: 06.05.2009
Сообщений: 15
По умолчанию

Цитата:
Сообщение от london735 Посмотреть сообщение
thank you for your nice replies but I cannot use wither a macro or the traditional autofilter methods,....I need this to be done with formulas alone...is there a way to do this?
with formulas
Вложения
Тип файла: zip EXAMPLE DATA SET.zip (12.9 Кб, 11 просмотров)
roplius вне форума Ответить с цитированием
Старый 05.07.2009, 02:49   #6
london735
Пользователь
 
Регистрация: 20.06.2008
Сообщений: 45
По умолчанию

Hello Roplius!
Sorry for the delayed reply. Can you please tell me what the "MyRow" expression stands for?
Thanks!!!
london735 вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Set oDoc = w.Documents.Add АлёнаP Microsoft Office Word 9 30.03.2009 16:21
2 задачки (String & Set ) mshunter Паскаль, Turbo Pascal, PascalABC.NET 7 08.01.2009 21:13
Макрос set attribute file oTyler Microsoft Office Excel 3 08.07.2008 13:20
ошибка CommandText does not return a result set furstenberg БД в Delphi 2 04.02.2008 17:38
Протокол защищенных электронных транзакций Set Nathan Помощь студентам 3 27.01.2007 16:08