Excel Question : Macro Vba

Discussion in 'Programming' started by Chaibim, Sep 6, 2013.

  1. #1
    I need to get help in this area as I'm really really NEW to VBA; I tried many codes found on the net and no luck .. Hope to find it here !

    Here is the question : let's say I have paper 1 with in column A many alert types and column B the place where it happened (I'm working for a alerts company and security), what I need to do is a code that reades column A and then column B, if there is more than 50 times same column A value , it puts it in paper 2 without putting it X number of times, only when column B is different.

    Exemple :

    Col A : Col B :
    Alert named 1 (50 times repeated) Chicago
    Alert named 1 (50 times repeated) Tunis
    Alert named 1 (50 times repeated) Tunis
    Alert named 1 (50 times repeated) Tunis
    Alert named 2 ohoa

    In paper 2 :
    Col A : Col B :
    Alert named 1 Chicago
    Alert named 1 Tunis
     
    Chaibim, Sep 6, 2013 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    Are you reading the papers from image, ocr or text?
     
    ThePHPMaster, Sep 6, 2013 IP
  3. sarahk

    sarahk iTamer Staff

    Messages:
    28,818
    Likes Received:
    4,536
    Best Answers:
    123
    Trophy Points:
    665
    #3
    That's quite straight forward.

    You can do it several ways but as a newbie I'd do it this way

    Create a spreadsheet which is called "Master Script.xls" or something similar

    Open up the spreadsheet with the information in it. When you talk about "paper" do you really mean worksheet? I'm continuing on that basis.
    From the info spreadsheet go to run the macro and run the script in the Master Script file.

    Now - the macro will expect to be started from the source file - as it helps it in referencing the documents and sheets.

    Your script will look down the info worksheet and find the values and compare them to values it will insert into the master script worksheet. If the value is there, it turns the next column over into a counter column and sets the value to 2, and after that just increments it.

    then when worksheet A is complete it scans down it's list to find those with a count that is greater than 50 and puts them in worksheet B.

    You can also do this with arrays but this will be
    • easier as a learning exercise
    • easier to debug and test
     
    sarahk, Sep 9, 2013 IP