montecarlo2012
Well-known Member
- Joined
- Jan 26, 2011
- Messages
- 985
- Office Version
- 2010
- Platform
- Windows
Hello.
I am trying to putting together some work but the second part is difficult to find on internet what specifically I need.
this is the first part of the code already accomplish with a lot help.
this code read an array of six columns and return the gaps between the same value, and every value have their own sheet to be display
now my problem is that the elementary basic code I did for the statistic propose have sheets that must be adjusted to according to what I am doing.
my workbook is in this link
worksheetindex.xlsm
and the code
IF
What I just said is no clear also you can see the development and effort I putting to accomplished this
as a reference how this work start, what I need, what I am looking for and all those question can found answer in this link
so what I need to add is this code:
I would like to be able to change the index value of the worksheet in order to display the results on the right location
Please,
if you read this post, leave at least a note, last time my post got 300 views and only one person was able to solve
I hope to have better luck this time
thank you for reading this.
I am trying to putting together some work but the second part is difficult to find on internet what specifically I need.
this is the first part of the code already accomplish with a lot help.
VBA Code:
Sub L_100m_multipleSheets()
Dim SrcWS As Worksheet, DestWS As Worksheet
Dim rngData As Range, cell As Range
Dim rngDest As Range
Dim i As Long, m As Long, n As Long
Dim j As Long
Set SrcWS = Sheet3 'location of the array to read
For j = 1 To 53
Worksheets.Add After:=Worksheets(Worksheets.Count)
Set DestWS = ActiveSheet
Set rngDest = DestWS.Range("C2")
n = 0
For i = 0 To 5
Set rngData = SrcWS.Range(SrcWS.Cells(2, 2 + i), SrcWS.Cells(SrcWS.Rows.Count, 2 + i).End(xlUp))
m = -1
For Each cell In rngData
If cell = j Then
rngDest.Offset(0, m) = n
n = 0
m = m + 1
Else
n = n + 1
End If
Next cell
Set rngDest = rngDest.Offset(16)
Next i
Next j
End Sub
now my problem is that the elementary basic code I did for the statistic propose have sheets that must be adjusted to according to what I am doing.
my workbook is in this link
worksheetindex.xlsm
and the code
IF
What I just said is no clear also you can see the development and effort I putting to accomplished this
as a reference how this work start, what I need, what I am looking for and all those question can found answer in this link
vba.- Adding Sheets.
Hello all. Sub S9_8() Dim SrcWS As Worksheet, DestWS As Worksheet Dim rngData As Range, cell As Range, M, N Dim rngDest As Range, i As Long Set SrcWS = Sheet1 '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Set DestWS = Sheet9...
www.mrexcel.com
so what I need to add is this code:
VBA Code:
Dim V, Rg As Range
With Application
For Each V In Split("B2 B18 B34 B50 B66 B82")
Set Rg = Range(V, Range(V).End(xlToRight))
Range(V)(3).Resize(4).Value2 = .Transpose(Array(.Average(Rg), .Count(Rg), .Max(Rg), .Mode(Rg)))
Next
End With
Dim Cl As Long
For Cl = 2 To Cells(2, Columns.Count).End(xlToLeft).Column
Cells(1, Cl) = Abs(Cells(2, Cl) - Cells(2, Cl + 1))
Cells(17, Cl) = Abs(Cells(18, Cl) - Cells(18, Cl + 1))
Cells(33, Cl) = Abs(Cells(34, Cl) - Cells(35, Cl + 1))
Cells(50, Cl) = Abs(Cells(51, Cl) - Cells(35, Cl + 1))
Cells(66, Cl) = Abs(Cells(67, Cl) - Cells(35, Cl + 1))
Cells(82, Cl) = Abs(Cells(83, Cl) - Cells(35, Cl + 1))
Next
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::::::::::::::::::::::::::::::::::::::::::B2::::::::::::::::::::::::::::::::::::::::::::::::::::::
Range("B8").Formula = "=COUNTIF(B2:XX2,B7)" 'QTY MODE
Range("B9").Formula = "=COUNTIF(B2:XX2,B2)" 'QTY LAST
Range("B11").Formula = "=average(B1:XX1)" ' average distribution B1
':::::::::::::::::::::::::::::::::::::::::: C 18:::::::::::::::::::::::::::::::::::::::::::::::::::::::
Range("B24").Formula = "=COUNTIF(B18:XX18,B17)" 'QTY MODE
Range("B25").Formula = "=COUNTIF(B18:XX18,B18)" 'QTY LAST
Range("B27").Formula = "=average(B17:XX17)" ' average distribution B17
':::::::::::::::::::::::::::::::::::::::::::D34::::::::::::::::::::::::::::::::::::::::::::::::::::::
Range("B40").Formula = "=COUNTIF(B34:XX34,B33)" 'QTY MODE
Range("B41").Formula = "=COUNTIF(B34:XX34,B34)" 'QTY LAST
Range("B43").Formula = "=COUNTIF(B33:XX34,B33)" 'average distribution B33
'.::::::::::::::::::::::::::::::::::::::::E50::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Range("B56").Formula = "=COUNTIF(B50:XX50,B49)" 'QTY MODE
Range("B57").Formula = "=COUNTIF(B50:XX50,B50)" 'QTY LAST
'::::::::::::::::::::::::::::::::::::::::::F66::::::::::::::::::::::::::::::::::::::::::::::::::::::
Range("B72").Formula = "=COUNTIF(B66:XX66,B65)" 'QTY MODE
Range("B73").Formula = "=COUNTIF(B66:XX66,B66)" 'QTY LAST
':::::::::::::::::::::::::::::::::::::::::::G82:::::::::::::::::::::::::::::::::::::::::::::::::::
Range("B88").Formula = "=COUNTIF(B82:XX82,B81)" 'QTY MODE
Range("B89").Formula = "=COUNTIF(B82:XX82,B82)" 'QTY LAST
Dim ws As Worksheet
Dim ColorRng As Range
Dim ColorCell As Range
Set ws = Worksheets("Sheet8") ' this number also need to be in a loop
Set ColorRng = ws.Range("B5,B21,B37,B53,B69,B85")
For Each ColorCell In ColorRng
If ColorCell.Value = Application.WorksheetFunction.Max(ColorRng) Then
ColorCell.Interior.Color = RGB(255, 153, 0)
End If
Next
Range("B15").Formula = "=IF(B2>=B7,""NO"",""YES"")"
Sheet4.Range("Y4").Value = Sheet8.Range("B45").Value 'B
Range("B31").Formula = "=IF(B48>=B23,""NO"",""YES"")"
Sheet4.Range("Z4").Value = Sheet8.Range("B34").Value 'C
Range("B47").Formula = "=IF(B34>=B39,""NO"",""YES"")"
Sheet4.Range("AA4").Value = Sheet8.Range("B47").Value 'D
Range("B63").Formula = "=IF(B4>=B55,""NO"",""YES"")"
Sheet4.Range("AB4").Value = Sheet8.Range("B63").Value 'E
Range("B79").Formula = "=IF(B66>=B74,""NO"",""YES"")"
Sheet4.Range("AC4").Value = Sheet8.Range("B79").Value 'AC=F/4
Range("B95").Formula = "=IF(B82>=B87,""NO"",""YES"")"
Sheet4.Range("AD4").Value = Sheet8.Range("B95").Value 'AD=G/4
'::::::::::::::::::::::decision table 2 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Range("B44").Formula = "=if(B9=4,""yes"",""no"")"
Sheet4.Range("J4").Value = Sheet8.Range("B44").Value ' this line on sheet (4) increase by one, in the next sheet would be J3 and the same with the other columns.
Range("B30").Formula = "=if(B25=4,""yes"",""no"")" 'this ranges are fix.
Sheet4.Range("K4").Value = Sheet8.Range("B30").Value
Range("B46").Formula = "=if(B44=4,""yes"",""no"")"
Sheet4.Range("L4").Value = Sheet8.Range("B46").Value
Range("B62").Formula = "=if(B57=4,""yes"",""no"")"
Sheet4.Range("M4").Value = Sheet8.Range("B62").Value
Range("B78").Formula = "=if(B73=4,""yes"",""no"")"
Sheet4.Range("N4").Value = Sheet8.Range("B78").Value
Range("B94").Formula = "=if(B89=4,""yes"",""no"")"
Sheet4.Range("O4").Value = Sheet8.Range("B94").Value
End Sub
[ATTACH type="full" width="515px"]41198[/ATTACH]
Please,
if you read this post, leave at least a note, last time my post got 300 views and only one person was able to solve
I hope to have better luck this time
thank you for reading this.