Consulting

Results 1 to 5 of 5

Thread: display records by office

  1. #1

    display records by office

    I am a newbie in Excel/VBA.
    would you please help me to figure out this project.
    First, get the data from source.
    Second, Display the data based on office in the certain office place in Result sheet.
    see attached excel file. would you help me
    the following is so far what I done;
    [VBA]
    Sub ExtractDept()
    Dim i As Integer
    Dim intCount As Integer
    Dim strDept As String
    Dim startpoint As String
    Dim Msg As String
    Dim rngCell As Range
    Dim strYesNo As String
    Application.DisplayAlerts = False
    'reference the range;NQ,SR,GP,WR,CC,DC
    strDept = Range(OFFICE)
    'startarea=NQ,SR,GP,WR,CC,DC
    startpoint = Range(startarea)
    'In a certain office area, paste records according to Office In Result sheet

    Sheets(strDept & "Sheet").Range("a1").Select
    ActiveSheet.Paste

    Do While Range("start").Offset(i, 1) <> ""
    If Range("start").Offset(i, 1) = strDept Then
    ' go to startpoint place ; startarea=strDept
    Range(Range("start").Offset(i, 0), Range("start").Offset(i, 4)).Copy
    intCount = intCount + 1
    sht.Range("a1").Offset(intCount, 0).Select
    sht.Paste
    End If
    i = i + 1
    Loop

    Columns.AutoFit
    ActiveWindow.DisplayGridlines = False


    End Sub
    [/VBA]

  2. #2
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Well right off the bat you have a named range (startarea) used in your macro that is not defined. What range would that be?
    Peace of mind is found in some of the strangest places.

  3. #3
    Quote Originally Posted by austenr
    Well right off the bat you have a named range (startarea) used in your macro that is not defined. What range would that be?
    Actually, it is physical areas for (NQ,SR,GP,WR,CC,DC) in resultsheet. I do not
    know how to define in the macro.
    would you mind see the attached file, there are the format box for NQ, SR,GP,WR,CC,DC
    for example, whenever the records in sourcesheets are match with NQ , go to paste them to NQ format.
    as well SR, go to paste them to SR format and so on..

    thank you for your response. can you help me.

  4. #4
    if it is hard, would you give me other ways to do or some idea.
    thanks for your kindness

  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Check that all your named ranges are valid and repost your sample.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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