+ Reply to Thread
Results 1 to 10 of 10

New to macros, looking for logic assistance

  1. #1
    Registered User
    Join Date
    06-23-2008
    Posts
    5

    New to macros, looking for logic assistance

    I have been given a task to take data from a spreadsheet i was to create and re-format it so that it has a list of names, and then all skills these people what by there names and how much time they have spent working on these tasks. So that there are no empty cells, and it looks neat and ordered.

    As it stands i have a spreadsheet with the max number of columns and 1647 rows, so i cant exactly do it without some help from a macro and my lack of experience with macros makes this alot harder for me.

    I need to produce a macro that will help me with my task, and was wondering if anyone had some hints as to how i can go about making this macro? i tried recording one but i screwed it up and my VBA good enough to go through and alter the code to make it do as i need it to.

    Any help / advice would be much apreciated.

    Thanks.
    Last edited by eastond; 06-23-2008 at 09:23 AM. Reason: title

  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
    Hi

    Can you upload an example of your workbook, leaving just a representative sample of rows rather than all 1647 if the file is large, and add some notes which explain what you're trying to achieve, which cells are involved, results you expect etc.

    This will better assist us to advise.

    Rgds

  3. #3
    Registered User
    Join Date
    06-23-2008
    Posts
    5
    i can't at the moment as i am at work and any sort of uploading is disabled for security, but i can take them home and upload screen shots of them when i get home. Roughly what i have is:

    _| Name | Name | Name |
    S_|_
    S_|_
    S_|_
    S_|_

    Its basicly names across the top, skills down the side, and then values in the coresponding cells, but some of them cells are empty. And what my boss wants is:

    _| Name | Skill | Value |
    _|_
    _|_
    _|_
    _|_



    Dont know if that helps for the moment?

  4. #4
    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
    Dont know if that helps for the moment?

    Yes probably. Am I correct in thinking therefore that at the moment you have a large matrix where many of the cells at the intersection of a name and a skill have no values at all, whereas you want a straightforward list where names may be repeated if someone has more than one skill, and where you will have many more rows but only three columns?

    Rgds

  5. #5
    Registered User
    Join Date
    06-23-2008
    Posts
    5
    You got the first part right

    What he wants is is something like:

    Persons name | Skill | Time |
    -----------------| Skill | Time |
    -----------------| Skill | Time |
    -----------------| Skill | Time |
    Persons name | Skill | Time |
    -----------------| Skill | Time |
    -----------------| Skill | Time |
    -----------------| Skill | Time |

    And so on, from the massive spreadsheet i have.

    thanks

  6. #6
    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
    Hi,

    Try the following. It assumes your data is on Sheet1 with the names starting in B1 and going across the columns and the skills in A2 going down the rows, and there is a Sheet2 which will receive the revised output.

    Please Login or Register  to view this content.
    HTH

  7. #7
    Registered User
    Join Date
    06-23-2008
    Posts
    5
    Thanks for the help

    Although there is a bug in the code
    " Sheet2.Range("B65536").End(xlUp).Offset(1, -1) = Range("B1").Offset(0, x - 1)"

    Any idea how to fix it? :S

    Thanks

  8. #8
    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
    I'd be surprised if there's a bug in the code since it works OK for me.

    Would you check that you do have a sheet with a VBA name 'Sheet2' that contains your original data. i.e. not just a sheet whose tab name says 'Sheet2' which may not necessarily be the VBA Sheet2. In the VBA Project explorer window the VBA sheet name is the first mentioned, followed in brackets by the tab name. I suspect whilst you might have a sheet named Sheet2 it's VBA name is some other number.

    Alternatively, you could change the line of offending code to the following. Assuming the sheet where you want the new layout to appear has a tab name say "New"

    Please Login or Register  to view this content.
    HTH

  9. #9
    Registered User
    Join Date
    06-24-2008
    Posts
    2

    Cool Macro help

    Fortunately macros are great for self-learning in VB. Starting a VB recording and taking several actions in the spreadsheet and then viewing the syntax provides a great start. UNFORTUNATELY there's much less you can learn this way in 2007 than in 2003 (recording many object manipulations isn't as simple in 2007). As for logic structure, the use of IF statements and Loops are probably where you want to start (aside from more basic data and storage logic).
    Beyond the basics there's a much wider world out there for application developers - but it's hard to tap into even with a source like Excel Bible or a supposedly VB oriented text.
    I would recommend a forthcoming text designed to ramp up skills from basic (or no) programming background into fairly advanced skills. Titled "Excel Basics to Blackbelt" by Cambridge. http://www.excelforum.com/index.php
    Last edited by royUK; 07-15-2008 at 03:18 AM.

  10. #10
    Registered User
    Join Date
    06-23-2008
    Posts
    5
    Thanks guys, its working now

    The help is much apreciated (however it's spelt)

+ 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