How can I copy the contents of one worksheet to another using a formula, not VBA or manual copy/paste, and have it skip blank rows? - excel-2007

Using a formula in Worksheet B, I want to automatically copy only rows containing data from Worksheet A to Worksheet B. The result should be all the data from worksheet A with no blank rows as shown below.
WORKSHEET A
A B C D
Row 1 Worksheet A Title
Row 2 Header A Header B Header C Header D
Row 3 31 32 33 34
Row 4 41 42 43 44
Row 5
Row 6 61 62 63 64
Row 7
Row 8 81 82 83 84
WORKSHEET B
A B C D
Row 1 Worksheet B Title
Row 2 Header A Header B Header C Header D
Row 3 31 32 33 34
Row 4 41 42 43 44
Row 5 61 62 63 64
Row 6 81 82 83 84
Row 7
Row 8
If possible (not a requirement), I'd like to be able to continue this process by copying non-blank rows from Worksheet C and adding them to the first available row in Worksheet B.
WORKSHEET C
A B C D
Row 1 Worksheet C Title
Row 2 Header A Header B Header C Header D
Row 3
Row 4 401 402 403 404
Row 5 501 502 503 504
Row 6
Row 7 701 702 703 704
Row 8
WORKSHEET B UPDATED
A B C D
Row 1 Worksheet B Title
Row 2 Header A Header B Header C Header D
Row 3 31 32 33 34
Row 4 41 42 43 44
Row 5 61 62 63 64
Row 6 81 82 83 84
Row 7 401 402 403 404
Row 8 501 502 503 504
Row 9 701 702 703 704
Thank you in advance for your help!
Dave

In Sheet1, cell E2 enter:
1
In cell E3 enter:
=IF(COUNTA(A3:D3)<>0,MAX(E1:E2)+1,"")
and copy down. We see:
NOTE All the "good" rows are marked sequentially.
In Sheet2, cell A2 enter:
=INDEX(Sheet1!A$2:A$8,MATCH(ROWS(1:$1),Sheet1!$E$2:$E$8,0),0)
copy both down and across. In Sheet2 we see:
EDIT#1:
To fix the first issue, replace:
=IF(COUNTA(A3:D3)<>0,MAX(E1:E2)+1,"")
with
=IF(COUNTA(A3:D3)<>0,MAX(E$1:E2)+1,"")
before the copy-down.
The second issue requires an adjustment to:
the 8 in the second sheet!

Related

SQL: Subtracting certain rows with restrictions from a data table into a new table

I Have a data table in postgresql which has these columns and some rows like this:
st
epochnum
satnum
l1
l2
c1
p1
p2
1
1
1
10
11
12
13
14
1
1
2
15
16
17
18
19
1
2
1
20
21
22
23
24
1
2
2
25
26
27
28
29
20
1
1
30
41
52
63
74
20
1
2
75
76
87
88
null
20
2
1
...
I want to get some pairs of rows that have the same value for epochnum and satnum but have different value in "st". By the way, I have a list that specifies which "st" pairs should be subtracted. Its just another table that looks like this:
st1
st2
1
20
The rows in the first table have to be subtracted in l1,l2,c1,p1 and p2 with same epochnum and satnum according to this table and then inserted into a new table like this:
epochnum
st1
st2
satnum
dl1
dl2
dc1
dp1
dp2
1
1
20
1
20
30
40
50
60
1
1
20
2
65
65
75
75
null
...
The actual data has more than 400000 rows that has same epochnums and satnums like this. I have tried java programming in net-beans and used loops to simply get queries for each row and make the new table.
But I think maybe it is not efficient and unnecessarily takes long time due to the lots of queries that has to be done in java.
I wonder if there is a way that this can be done using just a few queries, or creating extra tables and .... I haven't come up with the best solution yet.
Are you looking for joins like this?
select t1.st, t1.epochnum, t1.satnum,
(t2.l1 - t1.l1),
(t2.l2 - t1.l2),
(t2.p1 - t1.p1),
(t2.p2 - t1.p2)
from t t1 join
t t2
on t1.epochnum = t2.epochnum and
t1.satnum = t2.satnum join
pairs p
on t1.st = p.st1 and t2.st = p.st2

How merge several time series data sets to a data frame and then using cross validation on it?

Hi I have 50 time series datasets in 50 .CSV files and each of them have 2 column: data and label. exactly like below. each of these .CSV file contain more than 800,000 row of signal records and none of them is equal to each other
How i can merge these .CSV file in to a data frame in order to select training and testing data with Cross validation?
because i working with RNN the sequence of data is important.
DATA OF CASE 1:
Data label
23 A
88 A
56 B
87 B
56 c
87 D
17 C
44 B
12 A
----------------
DATA OF CASE 2:
Data label
13 A
98 B
56 B
77 C
49 D
89 c
19 B
23 B
32 A

Delete rows based on value of 3 cells

I am fairly new to VBA so what I am trying to do feels almost impossible.
I have an excel sheet with three columns showing the percentage of toner left.
Black Cyan Magenta Yellow
6 45 67 100
93 93 5 19
20 40 65 57
I want to know if it's possible to create a macro to look at all three columns per row and if all the values are higher than 10, to delete the row and if any of the 3 values is below 10 to keep the row and move on to the next one.
In this case, row 2 and 3 would be kept because there's values below 10 but row 4 would be deleted.
For i = Sheet.Cells(Rows.Count, "A").End(xlUp).Row to 2 Step -1
If Cells(i, Column1).Value2 > 10 And Cells(i, Column2).Value2 > 10 And Cells(i, Column3).Value2 > 10 Then
Rows(i).Delete
End If
Next i

Excel formula or VBA searching for matching values, every matching value found move to new column

I'm new to excel and have very basic knowledge of it. I hope that some one will by able to help me as I'm trying to find similar formula or VBA code for few days now and no luck.
I need formula or VBA to find same value in range and when first matching value find move to new column.
For example:
Value in A1 check against all values in column H and if same value found move that value to B1, then again value in A1 check against values left in H column if same found move to C1, every time finds A1 same as value in H column moves that value to new column D1, E1 .....continue until all values in H column have been checked and matching ones moved. After this value in A2 checked against all values in H column and all matching values moved to B2,C2,E2 etc. Continue until all values have been moved from column H.
This how data looks before moving:
0 A B C D E F G H
----------------------------------------------------------
1 123 123
2 256 123
3 333 123
4 123
5 123
6 256
7 256
8 333
9 333
10 333
11 333
12 333
13 333
After movment:
0 A B C D E F G H
----------------------------------------------------------
1 123 123 123 123 123 123
2 256 256 256
3 333 333 333 333 333 333 333
4
5
6
7
8
9
10
11
Something like this:-
Sub tester()
With ActiveSheet
For Each cell In .Range("A1:" & .Range("A1").End(xlDown).Address)
i = 1
For Each c In .Range("H1:" & .Range("H1").End(xlDown).Address)
If cell.Value = c.Value Then
cell.Offset(0, i).Value = c.Value
i = i + 1
End If
Next
Next
End With
End Sub
Note: This does not clear the results from run to run.

SPSS using value of one cell to call another cell

Below is some data:
Test Day1 Day2 Score
A 1 2 100
B 1 3 62
C 3 4 90
D 2 4 20
E 4 5 80
I am trying to take the values from column 'day' and 'day2' and use them to select the row number for the column score. For example for Test A I would like to find the sum of 100 and 62 because that is the values of the first and second rows of score. Test B I would like to find the sum of 100, 62 and 90.
Does anyone have any ideas on how to go about doing this? I am looking to use something similar to the indirect function in Excel? Thank You
The trick is to convert variable "Score" as a row. Could not think of an easy way how to avoid SAVE/GET - room for improvements.
file handle tmp
/name = "C:\DATA\Temp".
***.
data list free /Test (a1) Day1 (f8) Day2 (f8) Score (f8).
begin data
A 1 2 100
B 1 3 62
C 3 4 90
D 2 4 20
E 4 5 80
end data.
comp f = 1.
var wid all (12).
save out "tmp\data.sav".
***.
get "tmp\data.sav"
/keep score.
flip.
comp f = 1.
match files
/file "tmp\data.sav"
/table *
/by f
/drop case_lbl.
comp stat = 0.
do rep var = var001 to var005
/k = 1 to 5.
if range(k, Day1, Day2) stat = sum(stat, var).
end rep.
list Test Day1 Day2 Score stat.
The result:
Test Day1 Day2 Score stat
A 1 2 100 162
B 1 3 62 252
C 3 4 90 110
D 2 4 20 172
E 4 5 80 100
Number of cases read: 5 Number of cases listed: 5