ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Condensing a data range with only a few nonzero values??? (https://www.excelbanter.com/excel-programming/355610-condensing-data-range-only-few-nonzero-values.html)

Travis.Broersma

Condensing a data range with only a few nonzero values???
 
I have a large range (24 columns by 50 rows) and the majority of the cell
values are zero, but there are about 10-20 that are not. However, these
10-20 values change position depending on other data. Does anyone have a
macro that can find the cells that have values and put the values into the
first column of another worksheet?

Chip Pearson

Condensing a data range with only a few nonzero values???
 
Try something like

Dim Rng As Range
Dim Dest As Range
Set Dest = Worksheets("Sheet2").Range("A1")
For Each Rng In Range("A1:X50").Cells '<< Change range as
required
If Rng.Value < 0 Then
Dest.Value = Rng.Value
Set Dest = Dest(2, 1)
End If
Next Rng


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Travis.Broersma"
wrote in message
...
I have a large range (24 columns by 50 rows) and the majority of
the cell
values are zero, but there are about 10-20 that are not.
However, these
10-20 values change position depending on other data. Does
anyone have a
macro that can find the cells that have values and put the
values into the
first column of another worksheet?





All times are GMT +1. The time now is 07:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com