Closed Thread
Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    04-25-2009
    Location
    tehran
    MS-Off Ver
    Excel 2003
    Posts
    7

    a macro for comparing column A to H

    with hello and regards two all members and administrators
    i have this table
    COUNTRY1 EXPORT$ COUNTRY2 IMPORT$ SAME CODE EXPORT$ IMPORT$ 30% MINOR
    10190 117 10190 294
    10210 74 10210 138
    10290 16 10290 29
    10511 27 10511 11
    10519 127 10519 70
    10639 127 10639 47
    10690 19 10690 47
    … … … …
    … … … …
    … … … …
    961700 19 961700 18
    961800 558 961800 1
    970110 970 970110 27
    970190 116 970190 3
    970500 0 970500 3
    970600 0 970600 91,969

    Column A: Country1 Export Code
    Column B: Export value for Country 1
    Column C: Country2 Import Code
    Column D: Import value for Country 2
    ------------------- NOW ---------------------
    i want to fill in Column E to H with a macro
    Column E: same code in Column A and Column C
    Column F: export value for same code (from Column B)
    Column G: import value for same code (from Column D)
    Column H: 30 percent of Minor Value
    for example if F3 is 9000 and G3 is 1000 then H3 will be 2700 that is 30 percent of F3

    thanks a lot for your attention
    sincerely
    amin
    Last edited by VBA Noob; 04-25-2009 at 03:33 PM.

  2. #2
    Registered User
    Join Date
    04-25-2009
    Location
    tehran
    MS-Off Ver
    Excel 2003
    Posts
    7

    Lightbulb Re: a macro for comparing column A to H

    a better post here
    with hello and regards two all members and Mr. Excel
    i have this table
    A B C D E F G H
    COUNTRY1 EXPORT$ COUNTRY2 IMPORT$ SAME CODE EXPORT$ IMPORT$ 30% MINOR
    10190 117 10190 294
    10210 74 10210 138
    10290 16 10290 29
    10511 27 10511 11
    10519 127 10519 70
    10639 127 10639 47
    10690 19 10690 47
    … … … …
    … … … …
    … … … …
    961700 19 961700 18
    961800 558 961800 1
    970110 970 970110 27
    970190 116 970190 3
    970500 0 970500 3
    970600 0 970600 91,969

    Column A: Country1 Export Code
    Column B: Export value for Country 1
    Column C: Country2 Import Code
    Column D: Import value for Country 2

    excel 2003 file
    http://www.4shared.com/account/file/...brAl6Snyxwpbv0
    excel 2007 file
    http://www.4shared.com/account/file/...brAl6Snyxwpbv0

    NOW
    i want to fill in Column E to H with a macro
    Column E: same code in Column A and Column C
    Column F: export value for same code (from Column B)
    Column G: import value for same code (from Column D)
    Column H: 30 percent of Minor Value
    for example if F3 is 9000 and G3 is 1000 then H3 will be 2700 that is 30 percent of F3

    thanks a lot for your attention
    sincerely
    amin

  3. #3
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,477

    Re: a macro for comparing column A to H

    why a macro,? functions will do as you require, given your example and layout
    IN E2 =A2
    IN F2 =B2
    IN G2 = D2
    IN H2 =IF(F2<=G2,F2*30%,G2*30%)
    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Registered User
    Join Date
    04-25-2009
    Location
    tehran
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: a macro for comparing column A to H

    sorry for incorrect post. the correct table is here with approximately 120000 rows:

    A B C D E F G H
    COUNTRY1 EXPORT$ COUNTRY2 IMPORT$ SAME CODE EXPORT$ IMPORT$ 30% MINOR
    10190 117 10190 294
    10212 74 10210 138
    10290 16 10215 29
    10511 27 10210 11
    10639 127 10210 70
    10890 127 10639 47
    11141 19 10890 47
    … … … …
    … … … …
    … … … …
    961800 19 961700 18
    970110 558 961800 1
    986730 970 970110 27
    986730 116 970190 3
    995040 0 970500 3
    995040 0 970600 91,969

    I have duplicate cells within A and C columns and different codes between them. some codes are in A that is not in C and viceversa
    i do not want to comparing A and c columns in same rows. i want to
    1- comparing this A and C columns,
    2- extracting same codes of A and C in column E
    3- fill F and G columns with B and D values of Joint A and C codes
    4- computing 30 percent of major value in B and D in column H


    sincerely
    amin

  5. #5
    Registered User
    Join Date
    04-25-2009
    Location
    tehran
    MS-Off Ver
    Excel 2003
    Posts
    7

    Lightbulb comparing columns with a macro

    With Special Thanks to All members

    i correct my last past

    i have this table with approximately 120000 rows:

    A B C D E F G H
    COUNTRY1 EXPORT$ COUNTRY2 IMPORT$ SAME CODE EXPORT$ IMPORT$ 30% MINOR
    10190 117 10190 294
    10212 74 10210 138
    10290 16 10215 29
    10511 27 10210 11
    10639 127 10210 70
    10890 127 10639 47
    11141 19 10890 47
    … … … …
    … … … …
    … … … …
    961800 19 961700 18
    970110 558 961800 1
    986730 970 970110 27
    986730 116 970190 3
    995040 0 970500 3
    995040 0 970600 91,969

    this table has duplicate cells within A and C columns and some codes are different between A and C (some codes are in A that is not in C and viceversa)
    i want to:
    1- comparing this A and C columns,
    2- extracting same codes of A and C in column E
    3- fill F and G columns with B and D values of Joint A and C codes
    4- computing x (for example 30) percent of major value in B and D in column H


    sincerely
    amin

  6. #6
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,134

    Re: a macro for comparing column A to H

    Threads merged.

    Please continue in the same thread.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,134

    Re: a macro for comparing column A to H

    Please post a link to your cross-posts on other Excel forums.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Registered User
    Join Date
    04-25-2009
    Location
    tehran
    MS-Off Ver
    Excel 2003
    Posts
    7

    Lightbulb Re: a macro for comparing column A to H

    after running macro 1 to 3 rows for E to H columns will be such as this:
    A B C D E F G H
    COUNTRY1 EXPORT$ COUNTRY2 IMPORT$ SAME CODE EXPORT$ IMPORT$ 30% MINOR
    10190 117 10185 294 10190 117 138 35.1
    10210 74 10190 138 10210 74 11 3.3
    10290 16 10210 11 10639 50 47 5.4
    10639 27 10212 70 … … … …
    10639 23 10213 18 … … … …
    10890 127 10639 47 … … … …
    11141 19 10721 52 … … … …


    thanks a lot, please help

  9. #9
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,134

    Re: a macro for comparing column A to H

    Amin,

    Second request: Please read the forum rules, and then post a link to every other Excel forum where you have posted the same question.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  10. #10
    Registered User
    Join Date
    04-25-2009
    Location
    tehran
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: a macro for comparing column A to H

    hi man
    i correct my last post, because i fill in column A to H
    i only have a problem i want to solve it


    what do you thinks?!

  11. #11
    Forum Guru VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    12,009

    Re: a macro for comparing column A to H

    Your thread is being closed for non compliance with our rules. Please PM me when you have read the forum rules RULES and made the changes to your post accordingly, i will then unlock your post so you may continue with the thread!

    Post Closed

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

Thread Information

Users Browsing this Thread

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

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.2.0