![]() |
using macros to categorise a list of customers
Im trying to use macros to separate information on different customers. I
have all the information on an excel spreadsheet and need to separate customers into four different categories. Customers with the company name beginning A to GR, then GS to SA, SB to THEC and THED to Z. Any ideas? |
using macros to categorise a list of customers
The following macro examines a name stored in cell A1 and puts a catagory
number in cell B1. The macro uses (Z100:Z106) as a working area. You can pick any column of 7 unused cells. The catagory is the alphabetic (dictionary) position: 1 - before GR 2 - after GR, before GS 3 - after GS, before SA 4 - after SA, before SB 5 - after SB, before THEC 6 - after THEC, before THED 7 - after THED Sub katagory() ' gsnuxx Set workarea = Range("Z100") v = Range("A1").Value workarea.Offset(0, 0).Value = "GR" workarea.Offset(1, 0).Value = "GS" workarea.Offset(2, 0).Value = "SA" workarea.Offset(3, 0).Value = "SB" workarea.Offset(4, 0).Value = "THEC" workarea.Offset(5, 0).Value = "THED" workarea.Offset(6, 0).Value = v Set r = Range(workarea, workarea.Offset(6, 0)) r.Sort key1:=workarea For i = 1 To 7 If workarea.Offset(i - 1, 0).Value = v Then Range("B1").Value = i Exit Sub End If Next End Sub -- Gary''s Student gsnu200711 |
All times are GMT +1. The time now is 10:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com