• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Testing Default VB Code

r1c1

Administrator
Staff member
Attempt 1

Code:
sub thisCodeShouldHighlight()

Dim isWorking

isWorking = true

end sub
 
Can we change the text that appears above reply box then, to relay this info?
upload_2014-4-30_12-27-57.png
 
Testing comment indenture level
Code:
Sub GetUniqueList()
'Ctrl+Alt+u

    Dim rCell As Range
    Dim colUnique As Collection
    Dim sh As Worksheet
    Dim i As Long
   
    'only work on ranges
   If TypeName(Selection) = "Range" Then
       
        'create a new collection
       Set colUnique = New Collection
       
        'loop through all selected cells
       'and add to collection
       For Each rCell In Selection.Cells
            On Error Resume Next
                'if value exists, it won't be added
               colUnique.Add rCell.Value, CStr(rCell.Value)
            On Error GoTo 0
        Next rCell
       
        'make a new sheet to put the unique list
       Set sh = ActiveWorkbook.Worksheets.Add
       
        'Write the unique list to the new sheet
       For i = 1 To colUnique.Count
            sh.Range("A1").Offset(i, 0).Value = colUnique(i)
        Next i
       
        'sort with no headers
       sh.Range(sh.Range("A2"), sh.Range("A2").End(xlDown)) _
            .Sort sh.Range("A2"), xlAscending, , , , , , xlNo
       
    End If
   
End Sub
 
Back
Top