R
RussellT
Thanks in advance.
Which of the following ways is the best coding convention and why?
Private Sub()
Sheets("DevData").Range("SourceDev").AdvancedFilter Action:=xlFilterCopy,
CriteriaRange:=Sheets("FilterControl").Range("A28:Y29"), _
CopyToRange:=Sheets("Results").Range("A2:W2"), Unique:=False
end sub
Public Sub FilterDbase_Click()
Dim filtercontrolSheet As Worksheet
Dim resultsSheet As Worksheet
Dim devdataSheet As Worksheet
Set filtercontrolSheet = Sheets("FilterControl")
Set resultsSheet = Sheets("Results")
Set devdataSheet = Sheets("DevData")
devdataSheet.Range("SourceDev").AdvancedFilter Action:=xlFilterCopy,
CriteriaRange:=filtercontrolSheet.Range("A28:Y29"), _
CopyToRange:=resultsSheet.Range("A2:W2"), Unique:=False
End Sub
Public Sub FilterDbase_Click()
Dim SourceRng
Dim CritRng
Dim CopyToRng
Set SourceRng = Sheets("DevData").Range("SourceDev")
Set CritRng = Sheets("FilterControl").Range("A28:Y29")
Set CopyToRng = Sheets("Results").Range("A2:W2")
SourceRng.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=CritRng, _
CopyToRange:=CopyToRng, Unique:=False
End Sub
Which of the following ways is the best coding convention and why?
Private Sub()
Sheets("DevData").Range("SourceDev").AdvancedFilter Action:=xlFilterCopy,
CriteriaRange:=Sheets("FilterControl").Range("A28:Y29"), _
CopyToRange:=Sheets("Results").Range("A2:W2"), Unique:=False
end sub
Public Sub FilterDbase_Click()
Dim filtercontrolSheet As Worksheet
Dim resultsSheet As Worksheet
Dim devdataSheet As Worksheet
Set filtercontrolSheet = Sheets("FilterControl")
Set resultsSheet = Sheets("Results")
Set devdataSheet = Sheets("DevData")
devdataSheet.Range("SourceDev").AdvancedFilter Action:=xlFilterCopy,
CriteriaRange:=filtercontrolSheet.Range("A28:Y29"), _
CopyToRange:=resultsSheet.Range("A2:W2"), Unique:=False
End Sub
Public Sub FilterDbase_Click()
Dim SourceRng
Dim CritRng
Dim CopyToRng
Set SourceRng = Sheets("DevData").Range("SourceDev")
Set CritRng = Sheets("FilterControl").Range("A28:Y29")
Set CopyToRng = Sheets("Results").Range("A2:W2")
SourceRng.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=CritRng, _
CopyToRange:=CopyToRng, Unique:=False
End Sub