Hi Team,
How to use Enum in Function to reduce lenghty parameter in functions.
In my below code Can I use Enum for Optional parameter.?.. and how to use.
Below is a Table
Regards,
mg
How to use Enum in Function to reduce lenghty parameter in functions.
In my below code Can I use Enum for Optional parameter.?.. and how to use.
VBA Code:
Option Explicit
Sub Sort_Data()
Dim datarng As Range
With Sheets("Data")
Set datarng = .Range("A1:B" & .Range("B" & Rows.Count).End(xlUp).Row)
End With
'Sorting through Custom Function '('how to create and pass in Enum for Optional Parameter in Function)
Sort_Data_Asc datarng, datarng.Range("A1"), xlAscending,xlyes
End Sub
Function Sort_Data_Asc(rng As Range, k As Range, Optional Order1 As XlSortOrder = xlAscending, Optional Header As XlYesNoGuess = xlYes)
rng.Sort k, Order1, Header:=Header
End Function
Below is a Table
Name | Scores |
Rohit | 7000 |
Sachin | 6000 |
Virat | 9000 |
Yuvraj | 3000 |
zeb | 8000 |
Jadeja | 2500 |
Regards,
mg