+ Reply to Thread
Results 1 to 13 of 13

Newbie at Macros - tips for seemingly simple macro?

  1. #1
    Registered User
    Join Date
    12-06-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2010
    Posts
    68

    Newbie at Macros - tips for seemingly simple macro?

    Hello All,

    I am working on a project that currently does not include a great deal of data, and could easily be sorted by hand. However, this data is expected to increase exponentially, and I will thus need to create a macro that can do the following:

    Macro that starts with the contents of one file and splits them out by group (column C in this case), and creates a separate file for each group with all of the same information that is in this file. The group name should be include in the title.

    If anyone would be so kind as to offer me some help in creating this macro, I would greatly appreciate it.

    Thanks in advance!

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Newbie at Macros - tips for seemingly simple macro?

    Hi,

    Can I suggest that the first thing to do is use the macro recorder to capture the code for the actions you take in achieving your task.
    The code will not be the most elegant and will contain a lot of stuff that can either be deleted altogether or modified to make simpler. Once you have that I suggest you offer the code you have captured here and no doubt we can move this on for you by explaining how you can change it.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    01-21-2015
    Location
    California, USA
    MS-Off Ver
    2013
    Posts
    35

    Re: Newbie at Macros - tips for seemingly simple macro?

    I've also found that attaching an example file (or the actual file if possible) helps the gurus help you.

  4. #4
    Registered User
    Join Date
    12-06-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Newbie at Macros - tips for seemingly simple macro?

    The file included some data that I probably shouldn't share publicly, but I changed the names and removed the columns with figures. However, I can't seem to find an option to attach the file anywhere... sorry, it's been a while since I've posted here.

  5. #5
    Registered User
    Join Date
    01-21-2015
    Location
    California, USA
    MS-Off Ver
    2013
    Posts
    35

    Re: Newbie at Macros - tips for seemingly simple macro?

    If you click "Go Advanced" instead of using quick reply, there should be a new icon of a paperclip so that you can attach a file

  6. #6
    Registered User
    Join Date
    12-06-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Newbie at Macros - tips for seemingly simple macro?


  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Newbie at Macros - tips for seemingly simple macro?

    Hi,

    See attached. It uses the following macro plus some range names that you'll see in the workbook
    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    12-06-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Newbie at Macros - tips for seemingly simple macro?

    Below is the code that was generated. Basically, I just use advanced filter to copy only the data from my chosen category (group, Column C) to another location within the same workbook, and then I copy that data, paste it to another workbook, and save it to a location and file name of my choice.

    Sub Macro3()
    '
    ' Macro3 Macro
    '

    '
    Range("A8:AE40").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _
    "A2:AE3"), CopyToRange:=Range("A45"), Unique:=False
    Rows("45:52").Select
    Selection.Copy
    Windows("Book1").Activate
    ActiveSheet.Paste
    Windows("general 2015 percentages.xlsx").Activate
    End Sub

  9. #9
    Registered User
    Join Date
    12-06-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Newbie at Macros - tips for seemingly simple macro?

    Oh, I forgot to record the saving process, but when I redid it, it worked just like I wanted it to. However, I still want to be able to do the following:

    -Create a button on the spreadsheet that will run the macro with just one click

    -I want each file to save as 'Whatever the category is' followed by 'today's date and time, i.e. 072220151532'

    Would appreciate any help for these two things, or any suggestions to improve what I already have so far. Thanks!

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Newbie at Macros - tips for seemingly simple macro?

    Hi,

    Change the code in #7 from
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    12-06-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Newbie at Macros - tips for seemingly simple macro?

    Thanks very much for the help Richard. This is very close to working perfectly - however, each file is being saved with the wrong name, i.e. category PR being saved as APxxxxxxxxxx.

  12. #12
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Newbie at Macros - tips for seemingly simple macro?

    Hi,

    Sorry, this line

    Please Login or Register  to view this content.
    should be placed after the line

    Please Login or Register  to view this content.
    not before.

  13. #13
    Registered User
    Join Date
    12-06-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Newbie at Macros - tips for seemingly simple macro?

    Yep, that works - thanks very 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. [SOLVED] VB newbie- Problems with simple macro to clear combo box value
    By sdelphy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-10-2014, 03:42 PM
  2. Seemingly simple retrieval of Pivot Table data
    By DJCurtley in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-13-2013, 09:05 PM
  3. Issue with seemingly simple SUM formula
    By jwesterfield in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-25-2013, 09:28 AM
  4. Newbie - here to pick up some tips, tricks and assitance
    By lareya in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 02-15-2013, 01:03 AM
  5. Trouble defining variables in simple macro - newbie
    By poetstorm in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-21-2012, 11:52 PM
  6. Seemingly Simple But Odd Problem Question
    By xfreez99 in forum Excel General
    Replies: 2
    Last Post: 07-28-2008, 09:23 AM
  7. Macro newbie - simple copy/paste function
    By Nat in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2006, 12:40 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