If you go to www.scotlandspeople.gov.uk, you can do free searches, after setting up a free account. I just did a general search for rankin, applying a search option of "Name Variants", and came up with 4,186 Rankins from the time records were found in 1581 thru 1854 doing a search in the old parish registers. The statutory registers are 1855 and newer.
You can narrow your search by parish, date, county, births, deaths, marriages, and so on. If a record exists, its probably here. The search engine is inconsistent, so try looking from different points of view: like, I will not find a marriage for a known couple by using his name, but enter her name, and there it is. And so on. Good hunting.
I have Rankin's in my family line of Durhams in Ayr, so we intermarried somewhere. The further back you go the worse spelling gets, so keep that in mind as you search. Ancestry has much, but not all of the Scotlands People records in their database, as well,
Regards
Mark Durham