Combining Arrays and Removing Null Values

rappinkapc

New Member
Joined
Apr 22, 2009
Messages
1
I want to create a file where data from economics experiments can be entered on several different worksheets, and then a combined on a different worksheet. For example:

Worksheet 1 (Session 1, Round 1)
A
1 Price
2 15
3 14
4 13
5
6
7
etc.
Worksheet 2 (Session 1, Round 2)
A
1 Price
2 20
3 15
4 25
5 40
6
7
etc.


Worksheet 3 (The one I want to be able to create)
A B C
1 Session Round Price
2 1 1 15
3 1 1 14
4 1 1 13
5 1 2 20
6 1 2 15
7 1 2 25
8 1 2 40

The problem is, I don't know how many rows there will be in each worksheet (it varies each time the experiment is run). I am having trouble with two things. First, I can't figure out how to combine the "price" arrays into one array. Second, I can't figure out how to only display the non-null values (e.g. if I define my array for sheet 1 as A2:A40, and there are only 3 values, zeros will be displayed for the remaining values). I hope I am clear. If not, let me know what else I can clarify.

Thanks.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
suppose your data is in sheet 1 columns A,B,C,D. you want to combine columns B,C,D into one column
use this macro (modify to suit you)

Sub test()
Dim rng As Range, c As Range
Dim dest As Range
Columns("G:G").Delete
Set rng = Range(Range("b1"), Range("B1").End(xlDown).End(xlToRight))

For Each c In rng
Set dest = Cells(Rows.Count, "g").End(xlUp).Offset(1, 0)
dest = c
Next
Range(Range("g2"), Range("g2").End(xlDown)).Cut
Range("g1").Select
ActiveSheet.Paste

End Sub

regarding having only non null values sort it descding the null values will come down.

the sample sheet 1 is given below (the resutl is in column G)

******** language=JavaScript src="http://www.interq.or.jp/sun/puremis/colo/popup.js">*********>
Book1
ABCDEFG
115485
222254
332678
443682
558892
666345
72
86
97
103
116
128
138
148
159
166
173
184
Sheet1
 
Upvote 0

Forum statistics

Threads
1,215,506
Messages
6,125,197
Members
449,214
Latest member
mr_ordinaryboy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top