+ Reply to Thread
Results 1 to 6 of 6

Change adjacent cell depending on text

Hybrid View

  1. #1
    Registered User
    Join Date
    06-21-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Change adjacent cell depending on text

    Hi all, this might have to be slightly vague, so please bear with me. I can provide more info if required.

    (Excel 2003)

    One of my many spreadsheets contains two columns, B and C.
    Column C contains the name of a client.
    Column B contains the name of an employee.

    Each client is assigned a certain employee, and some employees look after multiple clients.
    However, in the form that I receive the spreadsheet, some of the employee names are missing or incorrect, so I have to fill them in depending on the client.

    EG: employee A looks after clients X and Z
    Employee B looks after client Y

    How can I make it so that column B (employee) is filled with the correct employee depending on the adjacent client in that row (column C?)

    I was thinking something like an "if colC = "client X" then colB = "employeeA" but I know nothing about macros. If I get a generic macro with placeholder names I can fill it myself.

    One catch: as I mentioned, some employees have one client, some have up to six.

    Another catch: I do NOT want it to select row 1, as that is a header column and has filters applied.

    Thanks in advance and sorry for the poor explanation, I will try to be as responsive as I can.
    Last edited by Tubby McChubbles; 06-28-2013 at 08:47 AM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Change adjacent cell depending on text

    Hi, Tubby McChubbles,

    if you add a worksheet showing the names of the client as well as the employee next to these you may look the function VLookUp for that without the use tof VBA.

    HTH,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    06-21-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Change adjacent cell depending on text

    I'm trying to automate the entire system upon a button press, and this stage is just one in a series. Can I place the vlookup to be performed within a sequence of macros?

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Change adjacent cell depending on text

    Hi, Tubby McChubbles,

    you may either place the formula into the cells showing to the worksheet in question with the names or evaluate it in VBA and deliver the response as a value to the cells. You may alter the range in which to do this either to only blank cells or all cells. So my answer is: yes, you can. Maybe use smaller procedures (like for any particular task which may be written and tested individually) and call them all from one master once everything is set up.

    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    06-21-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Change adjacent cell depending on text

    Right,
    I will go and flail around with that.

    Thanks for the quick help; I may be back in the functions forum soon.

  6. #6
    Registered User
    Join Date
    06-21-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Change adjacent cell depending on text

    OK, fixed it.

    For future reference, this is what I used:

    Sub acreps()
    For Each rw In ActiveSheet.UsedRange.Rows
      If rw.Columns("C") = "XXXXXXX" Then
        rw.Columns("B") = "YYYYYYYY"
      End If
      If rw.Columns("C") = "XXXXXXXX" Then
        rw.Columns("B") = "YYYYYYYY"
      End If
    Next rw
    
    
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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