I am hoping someone can help me with this. I have a Listing of Names (last name is in Column E = Field #5).
Example of my problem:
When looking for a range of names starting with the letter “A” to “C”, user is prompted to enter the 1st letter (A) and the last letter (C), A is entered into inputbox “from”, c into “fromt”. Running the code shown below, it only gives me names starting with A and B but omits C. If I want all names including C I have to enter D into “fromt”. Given my code, this does not make sense to me. What am I doing wrong?
Thank you, Uwe
Example of my problem:
When looking for a range of names starting with the letter “A” to “C”, user is prompted to enter the 1st letter (A) and the last letter (C), A is entered into inputbox “from”, c into “fromt”. Running the code shown below, it only gives me names starting with A and B but omits C. If I want all names including C I have to enter D into “fromt”. Given my code, this does not make sense to me. What am I doing wrong?
VBA Code:
Dim from As String, fromt As String
from = InputBox("From which 1st letter of Last Name", )
fromt = InputBox("To which 1st letter of Last Name ", )
With Workbooks("DMS Donors.xlsm").Sheets("Donors").Range("A1").CurrentRegion
.AutoFilter Field:=5, Criteria1:=">=" & from, Operator:=xlAnd, Criteria2:="<=" & fromt
End With
With ActiveSheet.AutoFilter.Range
.Copy Worksheets("DonorSearch").Range("A1")
End With
Workbooks("DMS Donors.xlsm").Sheets("Donors").AutoFilterMode = False
Application.CutCopyMode = 0
Thank you, Uwe