can I sort using column headings, in a macro, not "a1"
Not directly unless this is also a defined name (insert=Name=Define)
assume headers in row 1
Dim res as Variant
Dim rng as Range
res = Application.Match("Surname",rows(1),0)
if not iserror(res) then
set rng = rows(1).Cells(1,res)
else
msgbox "Not found"
Exit sub
end if
Range("A1").CurrentRegion.Sort Key1:=rng
--
Regards,
Tom Ogilvy
"John" wrote in message
...
I have written a macro which includes a sort.
Problem happens when I delete a column and then run the macro. The macro
automatically sorts on original column.
Can I use the column heading ie SURNAME to sort. This would be the same
heading after I delete a column, thus solve my problem.
Many thanks
John
|