+ Reply to Thread
Results 1 to 3 of 3

Copy/Pasting Macro Function

  1. #1
    Forum Contributor
    Join Date
    02-11-2009
    Location
    Montclair, NJ
    MS-Off Ver
    Excel 365
    Posts
    236

    Copy/Pasting Macro Function

    Hey,

    I'm working on a quality control project (for products with Model #'s "1098", "1190", & "1220") for the company I work for and I'm having an issue with a macro.

    I have data coming from worksheet "Sheet1" AB6:AB21, that's getting "sent" to worksheets "1098", "1190", & "1220" E86:E101, and "Sheet1" AC6:AC21 -> worksheets in E151:E166

    In "Sheet1" cell F4, you enter the Model # ("1098" "1190" "1220"). I'd like this data above to ONLY go to the corresponding worksheet as cell F4 and not ALL model # worksheets. Is there a way that I can do this?

    Thank you for your time,
    Bob
    Attached Files Attached Files
    Last edited by sighlent1; 02-22-2010 at 10:47 AM. Reason: Solved

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,910

    Re: Copy/Pasting Macro Function

    I am having a hard time trying to figure out specifically what you asking help for, but I'll give it a go.

    In "Sheet1" cell F4, you enter the Model # ("1098" "1190" "1220"). I'd like this data above to ONLY go to the corresponding worksheet as cell F4 and not ALL model # worksheets. Is there a way that I can do this?
    In Module1 you have the following line of code:
    Please Login or Register  to view this content.
    It takes the name in F4, which you mention above, and creates a reference to the corresponding worksheet, so you're on the right track. It works but forcing the conversion by concatenating a null string is a little clunky; I suggest this to make it more obvious what's going on:
    Please Login or Register  to view this content.
    Anyway, then the code goes ahead and does the copy for every individual sheet:
    Please Login or Register  to view this content.
    You can replace the above with this, to perform the copy for just that sheet. Is this what you need?

    Please Login or Register  to view this content.
    Also, your code appears to have "macro recorder bloat." The macro recorder records superfluous steps that are not necessary for things to work. In particular, you do not have to actually select a cell to do something to it. And you don't have to select a cell, then operate on the selection--you can just operate directly on the cell. For example the following code from Module1
    Please Login or Register  to view this content.
    can be simplified as
    Please Login or Register  to view this content.
    In a similar example,
    Please Login or Register  to view this content.
    becomes
    Please Login or Register  to view this content.
    This fix improves efficiency; efficiency is not often a consideration for many macros, but it also greatly helps readability and maintainability.

    You also have several Modules with no code. It would clean things up a bit to remove them.

    Hope you find this useful....
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    02-11-2009
    Location
    Montclair, NJ
    MS-Off Ver
    Excel 365
    Posts
    236

    Re: Copy/Pasting Macro Function

    Thank you sooooo much

    This is EXACTLY what I'm looking for

    Thank you,
    Bob

+ 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