Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27569

Basic help for a newbie please!

$
0
0
Hi - I know nothing about VB, and need to edit a macro created with Excel. Essentially it has included a specific range of cells despite the fact that they were selected before hitting record. What I need is to apply this macro to whatever cells I have selected at the time, not the ones specified. Any help anyone?

Code:

Sub OrderByColour()
'
' OrderByColour Macro
'
' Keyboard Shortcut: Ctrl+a
'
    ActiveWorkbook.Worksheets(" master").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets(" master").Sort.SortFields.Add(Range("G19:G27"), _
        xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = RGB(146, _
        208, 80)
    With ActiveWorkbook.Worksheets(" master").Sort
        .SetRange Range("A19:DW27")
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
End Sub

Thanks!!

Viewing all articles
Browse latest Browse all 27569

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>