Results 1 to 4 of 4

Search for text in multiple columns with same heading - excel Macro

Threaded View

  1. #1
    Registered User
    Join Date
    07-30-2013
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2010
    Posts
    2

    Search for text in multiple columns with same heading - excel Macro

    Hi Team,

    I am very new to excel macros. I tried to write a macro for one of our requirements.

    The macro renames the department based on the list of managers corresponding to that department.
    It should search for a manager name in the columns H to Q and accordingly rename the department. But it is searching only column H. Please help me out. The macro text for your reference.

    Sub DepartmentList()
       'ASSIGN DEPARTMENTS BASED ON MANAGER 
        Dim intDepartmentColumn As Integer
        Rows("1:1").Select
        intDepartmentColumn = Selection.Find(what:="Department", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Column
        Rows("1:1").Select
        Selection.Find(what:="Manager", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Select
        Selection.Offset(1, 0).Select
        Range(ActiveCell, Cells(ActiveSheet.UsedRange.Rows.Count, 17)).Select
        For Each cell In Selection.Cells
             Select Case cell.Value
                Case "Thuan Tran", "Deborah Donoghue", "Edmond Albert Navarro", "Christopher Arndt-Kohlway", "Chris Arndt-Kohlway", "Efren Saraza", "Rajesh Raghavendran", "Troy Rudy", "Colin Fraser", "Timothy Gleadle"
                    Cells(cell.Row, intDepartmentColumn) = "IT Operations"
    
                Case "Daniel Singleton", "Paul Brockman", "Stuart Johnston", "Darren Walton"
                    Cells(cell.Row, intDepartmentColumn) = "IS End User Computing"
    
                Case "John Goodreau", "Timothy Westcott", "Krishnan Balasubramanian", "Asheesh Chhabra", "Eric Keller", "Michael Galiardi", "Michel Roberge", "Mathew Griffin"
                    Cells(cell.Row, intDepartmentColumn) = "SDD"
    
                Case "Jeffrey Kase"
                    Cells(cell.Row, intDepartmentColumn) = "Information Assurance"
    
                Case "Venkatesh Appiya", "Anup Samantaray", "Lisa Rosenfeld"
                    Cells(cell.Row, intDepartmentColumn) = "Program Management"
    
                Case "Kavitha Ravella"
                    Cells(cell.Row, intDepartmentColumn) = "ITSM"
    
                Case "Jennifer Carr", "Dale Todd"
                    Cells(cell.Row, intDepartmentColumn) = "ITCM"
    
                Case Else
                    Cells(cell.Row, intDepartmentColumn) = "MISC"
    
            End Select
        Next
    End Sub
    The format of excel sheet is as follows. (headings)

    Number Short description Opened by Change Owner Department This Change Request is Unauthorized Reason Manager Manager Manager Manager Manager Manager Manager Manager Manager Manager
    Last edited by anytimesampath; 07-30-2013 at 08:16 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro Not Working for Search in Multiple Columns
    By vcs1161 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-07-2013, 03:42 PM
  2. importing info from text file with multiple heading through document to excel
    By neale scott in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 01-13-2013, 08:30 PM
  3. [SOLVED] Search multiple columns and return heading
    By Catsup in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-07-2012, 11:41 PM
  4. [Macro Help] Search Column in a Table and Return Heading
    By x3ldonx in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-30-2012, 06:18 PM
  5. [SOLVED] Trying to move columns based on heading text, PLEASE HELP
    By Brett Smith in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2006, 02:50 PM

Tags for this Thread

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