+ Reply to Thread
Results 1 to 2 of 2

Big project! Lots of little queries....

Hybrid View

  1. #1
    Registered User
    Join Date
    09-06-2006
    Posts
    10

    Smile Big project! Lots of little queries....

    Hey guys

    I'm currently undertaking a big project where I'll need dozens of macros (which I'm not an expert on!) so thought I'd ask on a single thread instead of loads of little ones.

    I'm making an interface where I can view information on companies based on raw data. I've made a macro where I copy a line of data from one sheet, and paste it into another so it's nicely arranged, with buttons which let me cycle through different rows (companies).

    Question1

    I have a list of employees of many different companies, and want to copy ONLY the employees that have a specific ID number. for example:

    COMPANY ID - Employee
    456 - Employee 1
    456 - Employee 2
    456 - Employee 3
    252 - Employee 1
    252 - Employee 2
    369 - Employee 1
    369 - Employee 2

    I want to copy the rows of employees who work for the company 252.

    How do I do this?

    TYIA

  2. #2
    Registered User
    Join Date
    08-09-2006
    Posts
    30
    assuming you can get the company number in column A and the employee name in comlumn B:

    Cell E1 = Count(A:A)
    Cell E2 = the company number youre looking for

    Sub copy()
    Dim compnum
    Dim looplength
    Dim currentcell
    looplength = Range("E1").Value
    currentcell = 1
    compnum = Range("E2").Value
    While currentcell <= looplength
    If Abs(Range("A" & currentcell).Value - compnum) = 0 Then
    Range("B" & currentcell).Select
    Selection.copy
    Range("C" & currentcell).PasteSpecial
    End If
    currentcell = currentcell + 1
    Wend
    Columns("C:C").Select
    Selection.Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

    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