Hi all,
Coming here again as I have a problem with my loop.
I am using this SerieLength in order to count the number of row so I can add different range of data one after the other.
I think that the counting is not working as when pasting the data on the new sheet and giving the new layout it applies only to a number of rows inferior to initial selected range.
Any idea on this would be welcomed with great appreciation.
Thanks
Here is what source data look like and highlighted is the range selection on "raw" sheet
And here is what I obtain on the new sheet. As you can see it seems like everything stopped after the 4th row whereas the selction was 6 rows in total
Coming here again as I have a problem with my loop.
I am using this SerieLength in order to count the number of row so I can add different range of data one after the other.
I think that the counting is not working as when pasting the data on the new sheet and giving the new layout it applies only to a number of rows inferior to initial selected range.
Any idea on this would be welcomed with great appreciation.
Thanks
VBA Code:
Sub DatAnalysis()
'add new working sheet
Dim SheetName As String
SheetName = Application.InputBox(Prompt:="Sheet name", Type:=2)
Sheets.Add(Before:=Worksheets("raw")).Name = SheetName
Worksheets(SheetName).Activate
With Sheets(SheetName)
'do some stuff
'Set up for loop
Dim SerieValue As Range
Dim SerieName As String
Dim Conc As Range
Dim Condi As Boolean
Dim CondiConc As Boolean
Dim SerieLentgh As Integer
Dim i As Integer
Dim aver As Range
Dim sd As Range
Dim j As Integer
j = 1
i = 1
Condi = False
Do Until Condi = True
'selection of series values
Worksheets("raw").Activate
Set SerieValue = Application.InputBox(Prompt:="Pick Serie or empty cell if no more serie", Type:=8)
If IsEmpty(SerieValue) Then Condi = True
If Condi = True Then Exit Do
If Not IsEmpty(SerieValue) Then Condi = False
If Condi = False Then GoTo continue
continue:
SerieLength = SerieValue.Rows.Count
Worksheets(SheetName).Activate
i = i + 1
SerieValue.Copy Destination:=Cells(9, i)
'selection of concentration range
Worksheets("raw").Activate
Set Conc = Application.InputBox(Prompt:="select concentration range", Type:=8)
Worksheets(SheetName).Activate
Conc.Copy Destination:=Cells(8, i)
'name the serie
SerieName = Application.InputBox(Prompt:="Please input serie name.", Type:=2)
Cells(7, i).Value = SerieName
Range(Cells(7, i), Cells(7, i + SerieLength)).Select
Selection.Merge
Selection.HorizontalAlignment = xlCenter
'transform data
Range(Cells(13, i), Cells(15, i + SerieLength)).FormulaR1C1 = "=(((R[-4]C[0]-R6C2)/R6C1)*100)"
'average and stdev
Set aver = Range(Cells(17, i), Cells(17, i + SerieLength))
aver.FormulaR1C1 = "=AVERAGE(R[-4]C[0]:R[-2]C[0])"
Set sd = Range(Cells(18, i), Cells(18, i + SerieLength))
sd.FormulaR1C1 = "=STDEV(R[-5]C[0]:R[-3]C[0])"
'ad a graph
'Looping increment
i = i + SerieLength
j = j + 1
Erase SerieLength
Loop
End With
End Sub
Here is what source data look like and highlighted is the range selection on "raw" sheet
test code.xlsm | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | |||
2 | |||||||||||||||
3 | CPP1 | CPP2 | bckgrnd +50water | bckgrnd +30water | |||||||||||
4 | 5 | 10 | 20 | 50 | 5 | 10 | 20 | 50 | 153 | 149 | |||||
5 | 55085 | 62062 | 58946 | 67406 | 64053 | 55146 | 59887 | 59444 | 166 | 119 | |||||
6 | 56549 | 54699 | 56668 | 59879 | 67417 | 52042 | 61013 | 67668 | 152 | 127 | |||||
7 | 36063 | 42238 | 44725 | 43414 | 42802 | 42365 | 49246 | 38807 | bckgrnd +40water | bckgrnd +20water | |||||
8 | neg+10uL water | neg+20uL water | neg +50ul water | 136 | 165 | ||||||||||
9 | 47389 | 42924 | 43375 | 48777 | 31897 | 39081 | 3202 | 27005 | 124 | 151 | |||||
10 | neg+30uL water | neg+40uL water | 16137 | 22837 | 140 | 171 | |||||||||
11 | 33599 | 35254 | 30960 | 30822 | 53962 | 20928 | bckgrnd +10water | ||||||||
12 | 144 | 163 | |||||||||||||
13 | 47389 | 166 | |||||||||||||
14 | 42924 | 0,1 | 0,2 | 1 | 2 | 3 | 4 | 2 | 5 | ||||||
15 | 43375 | 0,1 | 0,2 | 1 | 2 | 3 | 4 | 2 | 5 | ||||||
16 | 0,1 | 0,2 | 1 | 2 | 3 | 4 | 2 | 5 | |||||||
raw |
And here is what I obtain on the new sheet. As you can see it seems like everything stopped after the 4th row whereas the selction was 6 rows in total
test code.xlsm | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
1 | neg | bckgrnd | |||||||
2 | 47389 | 136 | |||||||
3 | 42924 | 124 | |||||||
4 | 43375 | 140 | |||||||
5 | |||||||||
6 | 44562,67 | 133,3333 | |||||||
7 | k | ||||||||
8 | 5 | 10 | 20 | 50 | 5 | 10 | |||
9 | 55085 | 62062 | 58946 | 67406 | 64053 | 55146 | |||
10 | 56549 | 54699 | 56668 | 59879 | 67417 | 52042 | |||
11 | 36063 | 42238 | 44725 | 43414 | 42802 | 42365 | |||
12 | |||||||||
13 | 123,3132 | 138,9698 | 131,9774 | 150,9619 | |||||
14 | 126,5985 | 122,447 | 126,8655 | 134,0711 | |||||
15 | 80,62728 | 94,48417 | 100,0651 | 97,12315 | |||||
16 | |||||||||
17 | average | 110,1797 | 118,6337 | 119,636 | 127,3854 | ||||
18 | stdev | 25,64578 | 22,48666 | 17,14057 | 27,53503 | ||||
fyuh |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B13:E15 | B13 | =(((B9-$B$6)/$A$6)*100) |
B17:E17 | B17 | =AVERAGE(B13:B15) |
B18:E18 | B18 | =STDEV(B13:B15) |