+ Reply to Thread
Results 1 to 9 of 9

VBA macro to find specific cells, copy the content and paste to ranges

  1. #1
    Registered User
    Join Date
    10-24-2014
    Location
    Dallas, Texas
    MS-Off Ver
    2007
    Posts
    5

    VBA macro to find specific cells, copy the content and paste to ranges

    Don't work with Excel much but have been asked to format an Excel report.

    Users get an Excel report like the one attached. It has a blank column A. They get a summary of the user and their total and then it reports for the next rep, etc, etc. users want to filter various columns. They are having an issue tying the reps name to a particular row. They can see what ones belong to the rep but when filtered the rows get out of order and they can't also filter by the name. They want to tie the name to every row the rep that owns the record. The only way I know of doing this is to look for the cell that has the first name (Total for Smith,Bill: 10
    ), copy it, move up one row over to column A and paste the name onto every record above until they hit say a blank cell (case # let's say). Then it needs to look for the next rep name and do the same thing. Any ideas? Thank you
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA macro to find specific cells, copy the content and paste to ranges

    Hello tauterouff,

    The macro below has been added to the attached workbook. There is button "RUN" that will execute the macro and add the names in column "A".

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    10-24-2014
    Location
    Dallas, Texas
    MS-Off Ver
    2007
    Posts
    5

    Re: VBA macro to find specific cells, copy the content and paste to ranges

    [SOLVED] Thank you so much!

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA macro to find specific cells, copy the content and paste to ranges

    Hello tauterouff,

    You're welcome.

  5. #5
    Registered User
    Join Date
    10-24-2014
    Location
    Dallas, Texas
    MS-Off Ver
    2007
    Posts
    5

    Re: VBA macro to find specific cells, copy the content and paste to ranges

    Leith, do you know what might be the cause when I try and run it on my Excel? I get the error message..."Runtime error '91': Object variable or With block variable not set". When I debug it takes me to this line..."Set RngBeg = Rng.Cells(1, 1)".

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA macro to find specific cells, copy the content and paste to ranges

    Hello tauterouff,

    Is your workbook layout the same as the example workbook?

    If your data starts in a different column then the macro will need to be adjusted.

  7. #7
    Registered User
    Join Date
    10-24-2014
    Location
    Dallas, Texas
    MS-Off Ver
    2007
    Posts
    5

    Re: VBA macro to find specific cells, copy the content and paste to ranges

    Here is an example with the data cleared off and most of the rows removed. I kept 2 groups of records at the top and below is just some category rollups. The report will be of varying lengths depending the timeframe it is run. It comes to us as a flat file with no formulas, etc. xls.
    Attached Files Attached Files

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA macro to find specific cells, copy the content and paste to ranges

    Hello tauterouff,

    Okay, this is very different than the example you posted.

    Does the second record start at row 29?

  9. #9
    Registered User
    Join Date
    10-24-2014
    Location
    Dallas, Texas
    MS-Off Ver
    2007
    Posts
    5

    Re: VBA macro to find specific cells, copy the content and paste to ranges

    Sorry about that. The first record starts at row 3 and shows their total at row 4. The 2nd record starts at row 5 (I guess I accidentally deleted off the name) and ends on row 27 (total), then gives a total for both records, and then at 29 lists the totals for each rep. Hope that clarifies it and thank you so much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to copy paste specific charts and ranges to PPT
    By akhileshgs in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-02-2014, 06:07 AM
  2. Find specific Data copy and paste into Cell Macro VBA
    By kunmateo93 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-06-2014, 10:17 AM
  3. [SOLVED] Find all cells with a specific background color then copy/paste to correct column
    By d_rose in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-20-2012, 10:18 AM
  4. copy & paste a specific content
    By ghappybee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-02-2010, 11:44 PM
  5. Macro-Copy&Paste Fixed Data Ranges Into Last Empty Cell of Specific Column
    By hailnorm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-26-2009, 10:15 PM

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