Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Commenting on Code
Hi all, I asked for help regrading some work and very kindly i was provided solution. Although i am very grateful i need to extend the ananlysi but i have no idea what the 2 modules below do. Can somebody pleas explain (very briefly) what each section does? I would really appreciate the help!! Many thanks, Carl 1- Code ------------------- Sub mmm() zonecode = Worksheets("sheet1").Range("a65536").End(xlUp).Row etypes = Worksheets("sheet1").Range("iv1").End(xlToLeft).Co lumn nextline = 2 For i = 2 To zonecodes zcode = Worksheets("sheet1").Cells(i, 1).Value For j = 2 To etypes etype = Worksheets("sheet1").Cells(1, j).Value enbr = Worksheets("sheet1").Cells(i, j).Value Worksheets("sheet2").Cells(nextline, 1).Value = zcode Worksheets("sheet2").Cells(nextline, 2).Value = etype Worksheets("sheet2").Cells(nextline, 3).Value = enbr nextline = nextline + 1 Next j Next i End Sub ------------------- 2 - Code ------------------- Sub HighTypes() Dim LastRow As Long, lRow As Long Dim ws2 As Worksheet, ws3 As Worksheet Dim Top As Long, ws3row As Long Dim ZoneStr As String Dim ans As Integer Dim rngHigh As Range Set ws3 = Worksheets("sheet3") With ws3 .Activate .Range("A2:C" & .Range("C2").End(xlDown).Row).ClearContents ws3row = 2 End With Set ws2 = Worksheets("sheet2") With ws2 LastRow = .Range("A2").End(xlDown).Row lRow = 2 Do Top = lRow ZoneStr = .Cells(Top, "A").Value Do lRow = lRow + 1 Loop While (ZoneStr = .Cells(lRow, "A")) ans = Application.WorksheetFunction.Max(.Range("c" & Top & ":C" & lRow - 1)) Set rngHigh = .Range("c" & Top & ":C" & lRow - 1).Find(what:=ans) If Not rngHigh Is Nothing Then .Range("A" & rngHigh.Row & ":C" & rngHigh.Row).Copy ws3.Range("A" & ws3row) ws3row = ws3row + 1 End If Loop While (lRow < LastRow + 1) End With End Sub ------------------- -- Carlthoma ----------------------------------------------------------------------- Carlthomas's Profile: http://www.excelforum.com/member.php...fo&userid=3370 View this thread: http://www.excelforum.com/showthread.php?threadid=53790 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Commenting out code | Excel Discussion (Misc queries) | |||
Commenting out Rows in VB | Excel Discussion (Misc queries) | |||
Better Excel commenting | Excel Discussion (Misc queries) | |||
Conditional Commenting | Excel Programming | |||
Commenting in Code | Excel Programming |