+ Reply to Thread
Results 1 to 11 of 11

Macro to Use Multiple Cells in Workbook to Create Code Cell in another Workbook

  1. #1
    Registered User
    Join Date
    06-01-2013
    Location
    Phoenix, Az
    MS-Off Ver
    Excel 2007
    Posts
    13

    Macro to Use Multiple Cells in Workbook to Create Code Cell in another Workbook

    I am looking to create a macro that will look at cells in one workbook and create one code in another workbook. The EFCodeCompare workbook has the information for the codes and the EF-FinalBook has the workbook where I'd like to add two columns (ItemCode and Classification) The item code looks at the EFCodeCompare for the cells in "Spec" and then the "Class" and then the "Size" example 5EE-0450-0020 and pastes it to the corresponding row under ItemCode in EF-FinalBook. It also looks at the "Desc" row and adds the new "Class" Row. I hope these two workbooks clear up what I'm looking for...

    Thank you!!
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: Macro to Use Multiple Cells in Workbook to Create Code Cell in another Workbook

    Hi
    I cannot see any relationship between the two Workbooks so how do we know what codes to pick up to generate the new code you are after?
    Tony

  3. #3
    Registered User
    Join Date
    06-01-2013
    Location
    Phoenix, Az
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Macro to Use Multiple Cells in Workbook to Create Code Cell in another Workbook

    Sorry for the confusion, the row with Spec in "EF-FinalBook" should look for all items in "EFCodeCompare" with the same spec. It then looks at the Desc in the "EF-FinalBook" and the Description in "EFCodeCopare". The Description gives the second part of the code (usually 4 numbers) and also adds the column for the Class column in "EF-FinalBook". The final part of the code is from the NPD column in "EF-FinalBook" and looks at the Size column in the "EFCodeCompare" and gets the code for that. Basically there are 3 parts to the code xxx-xxxx-xxxx. The first is the spec, the second is the description code, and the third is the size code. I can create a flow chart if that would help?

  4. #4
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: Macro to Use Multiple Cells in Workbook to Create Code Cell in another Workbook

    Hi
    The problem I am having is that there appears to be no logical relationship between the two Workbooks. For example:
    EF-FinalBook : Row 8 : Spec = 6EEP
    There are 11 of these codes in the Compare Workbook - how do I know which one to pick up?
    Also the 4 digit number is in the Code column NOT the Description column!
    And there is no Size against any of the entries of 6EEP.

    Without logical relationships between the two worksheets we are stumped .

    Tony

  5. #5
    Registered User
    Join Date
    06-01-2013
    Location
    Phoenix, Az
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Macro to Use Multiple Cells in Workbook to Create Code Cell in another Workbook

    Here is a flow diagram of what I am trying to work out...

    ProgramFlow.JPG

  6. #6
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: Macro to Use Multiple Cells in Workbook to Create Code Cell in another Workbook

    Hi
    I understand what you are trying to achieve however let me see if I can explain the problem more clearly.
    If you take each row in Columns A to D in the ColumnCompare workbook each row would be one record. However in columns E and F the entries there bear no logical relationship to each row in Columns A to D. In fact Rows 24 to 35 in Column E and F have no Size or Code. So the problem remains as to how we link the correct size to the correct record in columns A to D. We can generate a code quite easily but it would be pure guesswork.
    Hope this makes sense.
    Tony

  7. #7
    Registered User
    Join Date
    06-01-2013
    Location
    Phoenix, Az
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Macro to Use Multiple Cells in Workbook to Create Code Cell in another Workbook

    Thanks Tony,

    I understand...what if I take each section of rows, copy and give it the possible sizes so they have a relationship with the information in the rest of the row? Something like this revision to the sheet?

    EFCodeCompare-Rev1.xlsx

  8. #8
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: Macro to Use Multiple Cells in Workbook to Create Code Cell in another Workbook

    Hi
    We are getting there .
    In the Code Compare book there is no entry under 6EEP that matches the NPD2 entry of 0.3125 in so a code can never be generated.
    This should explain why there needs to be a match for each field in both Workbooks.
    Tony

  9. #9
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: Macro to Use Multiple Cells in Workbook to Create Code Cell in another Workbook

    Hi
    Please find herewith an example of how it could work once you have all the correct details in your Workbooks. I am out of the country for a week from tonight and did not want to leave you without a possible solution. Let me know if it provides you with what you need.
    Good luck.
    Tony
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    06-01-2013
    Location
    Phoenix, Az
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Macro to Use Multiple Cells in Workbook to Create Code Cell in another Workbook

    Tony,

    Thank you so much!! The formula's worked great! The only thing that I am having a problem with now is using them in the macro. I tried using double quotes, but it is still erroring at this line...

    ActiveCell.FormulaR1C1 = "=IF(ISNA(VLOOKUP(A2,'X:\BOMtoBOQ Macro\[ItemCodeCompare.xlsx]Sheet1'!$A$1:$G$65536,1,FALSE)),""ITEM NOT FOUND"",[@Spec]&"" - ""&VLOOKUP(A2,'X:\BOMtoBOQ Macro\[ItemCodeCompare.xlsx]Sheet1'!$A$1:$E$65536,5,FALSE)&"" - ""&VLOOKUP(A2,'X:\BOMtoBOQ Macro\[ItemCodeCompare.xlsx]Sheet1'!$A$1:$G$65536,7,FALSE))"
    Last edited by michaelpair; 06-25-2013 at 12:36 PM.

  11. #11
    Registered User
    Join Date
    06-01-2013
    Location
    Phoenix, Az
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Macro to Use Multiple Cells in Workbook to Create Code Cell in another Workbook

    After playing with this one, I found that taking out the R1C1 after ActiveCell.Formula did the trick... Thank you!!

+ 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

X vBulletin 4.1.8 Debug Information

  • Page Generation 0.08152 seconds
  • Memory Usage 9,090KB
  • Queries Executed 15 (?)
More Information
Template Usage (32):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)footer
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (11)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (4)navbar_noticebit
  • (6)option
  • (4)postbit_attachment
  • (11)postbit_legacy
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (4)showthread_bookmarksite
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper
  • (1)vbseo_linkbackmenu_entry 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (39):
  • ./vbseo.php
  • ./env.php
  • ./vbseo/includes/functions_vbseo.php
  • ./vbseo/includes/functions_vbseo_pre.php
  • ./vbseo/includes/functions_vbseo_url.php
  • ./vbseo/includes/functions_vbseo_createurl.php
  • ./vbseo/includes/functions_vbseo_db.php
  • ./vbseo/includes/functions_vbseo_vb.php
  • ./vbseo/includes/functions_vbseo_seo.php
  • ./vbseo/includes/functions_vbseo_misc.php
  • ./vbseo/includes/functions_vbseo_crr.php
  • ./vbseo/includes/functions_vbseo_cache.php
  • ./vbseo/includes/functions_vbseo_hook.php
  • ./vbseo/includes/functions_vbseo_startup.php
  • ./includes/config.php
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/functions.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/functions_cforum.php
  • ./includes/functions_facebook.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php
  • ./includes/functions_notice.php 

Hooks Called (47):
  • init_startup
  • friendlyurl_resolve_class
  • database_pre_fetch_array
  • database_post_fetch_array
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • fetch_musername
  • cache_templates
  • template_register_var
  • parse_templates
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • reputation_image
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • showthread_bookmarkbit
  • navbits
  • navbits_complete
  • showthread_complete


Search Engine Friendly URLs by vBSEO 3.6.0 RC 1