Results 1 to 1 of 1

VBA to automatically allocate a new person to an account

Threaded View

  1. #1
    Registered User
    Join Date
    08-07-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    2

    VBA to automatically allocate a new person to an account

    Hi all

    I need help with some coding - i have attached a dummy version of my report with name changes

    I have produced a spreadsheet which the main function is to automatically allocate a new account manager to an account but this cannot be the last account manager, it has to be someone different.

    I have set the spreadsheet up using formulas to randomly select a person from the individual teams - this all works perfectly.

    What I am having trouble with is making it recognise the last account manager so when it radomly selects a new person, it is a different person to the last account manager.

    I have probably set this up in quite a long way, but it works, I am just stuck with this last bit.

    I have recorded a macro as a button which says "allocate now".

    What I have been trying to do is, I have set up a formlua in the end column which picks up if the new account manager is the same as the old account manager it displays "yes". I wanted to add on additional VBA to the macro, so when I press "allocate now" it will radomly allocate an acocunt manger, scroll down the last collumn and if any display "yes" it will re-calcuate this collumn.

    This is the code i have so far (which does not work):-

    Sub Button1_Click()

    Dim a As Integer
    Dim x As Integer
    Dim y As String
    Dim z As String

    x = 8
    a = 9

    Do Until x = 2000

    ActiveCell = yes

    y = "O" & CStr(x)
    z = "O" & CStr(a)


    Range(y).Select
    ActiveCell.FormulaR1C1 = "=RC9&RANDBETWEEN(1,COUNTIF(TEAMS!R1C2:R260C2,RC9))"
    Range(z).Select

    x = x + 1
    a = a + 1

    Loop

    x = 0
    a = 0
    x = 8
    a = 9
    z = ""

    Do Until x = 2000

    Range("P8:P800").Select
    ActiveCell = yes

    y = "P" & CStr(x)
    z = "O" & CStr(a)

    If Range(y).Value = "yes" Then

    Range(z).Select
    ActiveCell.FormulaR1C1 = "=RC9&RANDBETWEEN(1,COUNTIF(TEAMS!R1C2:R260C2,RC9))"

    End If

    x = x + 1
    a = a + 1

    Loop


    End Sub



    Hope that all makes sense - any chance of some help??

    Many thanks!
    Last edited by Chaz-13; 08-07-2013 at 06:52 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Transpose/Pivot multiple rows per person into 1 row per person with fixed columns
    By MaestroEnrique in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-13-2013, 06:35 AM
  2. Replies: 1
    Last Post: 09-07-2012, 12:00 PM
  3. Replies: 9
    Last Post: 03-12-2012, 05:30 AM
  4. Replies: 3
    Last Post: 02-27-2007, 05:27 AM
  5. [SOLVED] How to calculate a person's age taking into account their birthda.
    By CPD174 in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 09-06-2005, 12:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1