+ Reply to Thread
Results 1 to 3 of 3

excel macro basic program

  1. #1
    Registered User
    Join Date
    05-30-2008
    Posts
    7

    excel macro basic program

    I am trying to select data from a school data base. What I do is enter the school’s ID number, then have the find function finding the school ID then highlight the data cells I need. The code is below.

    ActiveCell.Select
    ActiveCell.FormulaR1C1 = "400560010260000"
    ActiveCell.Offset(1, 0).Range("A1").Select
    Windows("school08.xlsm").Activate
    Cells.Find(What:="400560010260000", After:=ActiveCell, LookIn:=xlFormulas _
    , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate
    ActiveCell.Offset(0, 5).Range("A1:B1").Select
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .Color = 65535
    .TintAndShade = 0
    .PatternTintAndShade = 0
    End With
    ActiveCell.Select
    End Sub


    The problem is the areas in bold. What I cannot do is figure out how to enter in separate school ID numbers because the macro has already embedded in it the original data in the copy function which I used to enter into the find function. What I need to do is enter in some sort of variable in the first bold section, and have the data in the variable be used in the find function in the second bold area. I need to declare a variable, and maybe use an array with all of the school ID’s I’m looking for, then use some sort of Loop statement so that the actions of cell find and select cells can be run with each new data in the array. I’m sure this is a quick fix, but I’m not as versed as writing the code yet, so I thought I would ask for assistance. Any ideas?

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: excel macro basic program

    Please take a few minutes to reread the forum rules, amend your thread title accordingly, and edit your post to add CODE tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    05-30-2008
    Posts
    7

    Re: excel macro basic program

    thanks for the quick response. sorry for not reading the forum rules, got a bit hasty there.
    Pji

+ 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