+ Reply to Thread
Results 1 to 32 of 32

Macros: Data cleaning macros not producing expected outputes.

  1. #1
    Registered User
    Join Date
    06-03-2011
    Location
    chertsey, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    Macros: Data cleaning macros not producing expected outputes.

    I want the attached excel document (001) to take the pasted data (as in 002 sheet 2) and after macros cleaner1 (0004) and cleaner 2, (0005) produce a final output as in the output doc.
    However after running macro cleaner 1, the sum formula on sheet 2 under column P changes in the number of cells to be added up.

    Then after running cleaner 2, I noticed that although the entire sheet 1 uses fixed references, some of the cell references have been changed such that they are fetching the wrong data. Also, in sheet 2, under number 3, there is an "SP" that should have been deleted just as there are some blanks under column T that should have been deleted.
    All the cleaner codes are included below.
    Thanks.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by bertlogdi1; 06-07-2011 at 12:34 PM. Reason: To conform to rules.

  2. #2
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: What is wrong with my code?

    Quote Originally Posted by bertlogdi1
    What is wrong with my code?
    It is not wrapped in code tags. Please do so, and then I will be better able to help you. See the Forum Rules on how to wrap your code in code tags.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: What is wrong with my code?

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found hereYour post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    PLEASE PM WHEN YOU HAVE DONE THIS AND I WILL DELETE THIS POST
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    06-03-2011
    Location
    chertsey, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: What is wrong with my code?

    Thanks for your advice. I have amended my post.
    Rgds.



    Quote Originally Posted by Whizbang View Post
    It is not wrapped in code tags. Please do so, and then I will be better able to help you. See the Forum Rules on how to wrap your code in code tags.

  5. #5
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros: Data cleaning macros not producing expected outputes.

    Ok, first we need to clean up your code. .Select is rarely needed in VBA. The recorder puts them there because, while you are recording, you are actually selecting cells. But, they aren't needed to do most operations. The code below does the same thing as your code, but with most of the Select statements removed. This will make the cleaner routines run much faster. There are a couple of them left, but I will post some code later that will remove them completely. I just wanted to take things one step at a time.

    Please Login or Register  to view this content.
    Last edited by Whizbang; 06-07-2011 at 01:39 PM.

  6. #6
    Registered User
    Join Date
    06-03-2011
    Location
    chertsey, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Macros: Data cleaning macros not producing expected outputes.

    Thank you Whizbang.
    The first part works well once the first line range is amended for the missing colon. However the second one has not worked as it keeps complaining of this line:
    Please Login or Register  to view this content.
    Rgds.

    [QUOTE=Whizbang;2539837]Ok, first we need to clean up your code. .Select is rarely needed in VBA. The recorder puts them there because, while you are recording, you are actually selecting cells. But, they aren't needed to do most operations. The code below does the same thing as your code, but with most of the Select statements removed. This will make the cleaner routines run much faster. There are a couple of them left, but I will post some code later that will remove them completely. I just wanted to take things one step at a time.

  7. #7
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros: Data cleaning macros not producing expected outputes.

    Ok. That is a nice segue into my next code sample. The below code does a few things to my previous example. First, it introduces a variable to store data to be used in later lines of code. The second thing introduced is the use of worksheet functions in code, specifically the Match() function. This replaces the need to use .Find. Third, I replaced the .Copy method with a straight assigning of values. This is much faster than .Copy. The last thing this code block does is to remove the "With ActiveSheet" lines. There was no need for them. Unless Range() is preceeded with some sort of definition of which sheet is bein enacted upon, the ActiveSheet is assumed. So Range("A1") is the same as ActiveSheet.Range("A1").

    Again, the below code does the same thing as your code, but it is cleaner. We'll get to your problem and solution, but I want to make sure you understand the differences, and maybe enable you to customize it as needed.

    Please Login or Register  to view this content.
    Last edited by Whizbang; 06-07-2011 at 05:12 PM.

  8. #8
    Registered User
    Join Date
    06-03-2011
    Location
    chertsey, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Macros: Data cleaning macros not producing expected outputes.

    Thanks for understanding my stiched up codes and introducing these improvements. This is the first time I have written a VBA code. I am learning much from you and others on this forum. Thank you all.

    [QUOTE=Whizbang;2540037]Ok. That is a nice segue into my next code sample. The below code does a few things to my previous example. First, it introduces a variable to store data to be used in later lines of code. The second thing introduced is the use of worksheet functions in code, specifically the Match() function. This replaces the need to use .Find. Third, I replaced the .Copy method with a straight assigning of values. This is much faster than .Copy. The last thing this code block does is to remove the "With ActiveSheet" lines. There was no need for them. Unless Range() is preceeded with some sort of definition of which sheet is bein enacted upon, the ActiveSheet is assumed. So Range("A1") is the same as ActiveSheet.Range("A1").

    Again, the below code does the same thing as your code, but it is cleaner. We'll get to your problem and solution, but I want to make sure you understand the differences, and maybe enable you to customize it as needed.
    Last edited by bertlogdi1; 06-07-2011 at 05:34 PM. Reason: Grammatical

  9. #9
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros: Data cleaning macros not producing expected outputes.

    There was a typo in my previous code. I forgot to put the : in the "Range("A" & lngSrchRow & "T" & lngSrchRow).Value = Range("A25:T25").Value" statements.

    The code below fixes the typo and also shortens Cleaner1(). The next code I provide will actually address your problems listed in the original post.

    Please Login or Register  to view this content.
    Last edited by Whizbang; 06-08-2011 at 09:01 AM.

  10. #10
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros: Data cleaning macros not producing expected outputes.

    So, I am finally looking at your attached workbooks and running through your code (up until now I haven't been testing the code I provide. I've just been drafting it in Notepad++ and then pasting it here.). I had forgotten that Match() cannot be used to find blank cells.

    So, here is a replacement for the Match() function method above. I know I promised the next code I provided would be a solution to your problems, but I figured I would address my own errors seperately.

    Please Login or Register  to view this content.

    Ok, now while running your code on the provided sample workbooks, I have come upt with a couple of questions/comments.

    Why are you testing for the U column formula(s) to evaluate to six? Meaning, why copy data? It seems to me this is just to create filler rows. Why is this necessary? Why not just delete all blank rows?

    This code:
    Please Login or Register  to view this content.
    doesn't seem to do anything. You have just filled the first 190 rows with a formula. So this line of code does nothing but delete the rows from 191 to 500. xlCellTypeBlanks does not consider a cell blank if it has a formula in it, even if the formula evaluates to blank. Wait... I just reread your original post and realized this is one of your issues you describe. Nevermind. I will address this when I post my final code.

    Lastly, is there a step you take between Cleaner1() and Cleaner2()? Meaning, I would like to merge the two together into a single procedure, and so get rid of the unecessary insertion of rows blank rows only to have them deleted a moment later. Also, combining them will enable me to run loops to identify the rows to adjust, insert or delete without hard-coding the range addresses. Does this agree with your goals?

  11. #11
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macros: Data cleaning macros not producing expected outputes.

    @Whizbang,

    Please Login or Register  to view this content.



  12. #12
    Registered User
    Join Date
    06-03-2011
    Location
    chertsey, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Macros: Data cleaning macros not producing expected outputes.

    Hi Whizbang,
    Thanks a zillion for your help. In the beginning, my aim was to copy data from a website to clipboard and then a macro will paste those 7 data and then go on to clean the data. Then these data will be accessed by the formula in sheet 1 to finally produce a report which will be printed.
    However, being new to VBA, I could not handle the Microsoft form 2.0 library DataObject which is what is required. So I am manually pasting the first data which is the main block and contains 5 lines of past performances per racer. So I try to clean this bit up a bit with cleaner1 and then I will add one data set per racer hence the extra 6 data sets that make it all 7 sets of copied data. The problem is that these are of different length but not more than 15 hence my adding 15 lines to the initial data. Then, I use cleaner 2 to clean the data finally.
    The aim is to have only 6 real races left behind for each racer. Hence my crude use of turning non real races like when the racer was a non-runner (NR), ran alone (solo) or with less than 5 others inchich case it is a T race into blanks for deletiing. Infact any race not having an A in the grade or having an NR entry anywhere in the row is to be removed. So I try to change this to blanks and then delete them along with other real blanks. Coming to the 6 in U, there are sometimes when an entrant has less that 6 races in its life time. In such case, I make up the number by repeating the very first race that has an "A" in the grade.
    I hope I have clarified a few things. Please re-ask any questions I did not address well.
    More importantly, thanks for your kindness.
    Rgds.

    Ok, now while running your code on the provided sample workbooks, I have come upt with a couple of questions/comments.

    Why are you testing for the U column formula(s) to evaluate to six? Meaning, why copy data? It seems to me this is just to create filler rows. Why is this necessary? Why not just delete all blank rows?

    This code:
    Please Login or Register  to view this content.
    doesn't seem to do anything. You have just filled the first 190 rows with a formula. So this line of code does nothing but delete the rows from 191 to 500. xlCellTypeBlanks does not consider a cell blank if it has a formula in it, even if the formula evaluates to blank. Wait... I just reread your original post and realized this is one of your issues you describe. Nevermind. I will address this when I post my final code.

    Lastly, is there a step you take between Cleaner1() and Cleaner2()? Meaning, I would like to merge the two together into a single procedure, and so get rid of the unecessary insertion of rows blank rows only to have them deleted a moment later. Also, combining them will enable me to run loops to identify the rows to adjust, insert or delete without hard-coding the range addresses. Does this agree with your goals?[/QUOTE]

  13. #13
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macros: Data cleaning macros not producing expected outputes.

    or ?

    Please Login or Register  to view this content.
    Last edited by snb; 06-08-2011 at 05:41 PM.

  14. #14
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros: Data cleaning macros not producing expected outputes.

    Quote Originally Posted by snb View Post
    or ?

    Please Login or Register  to view this content.
    I get an error "Cannot use that command on overlapping sections". But, that is because the row number overlap some. If you do them one at a time, they work out.

    Anyway, the code I am working on gets rid of that bit. It loops through each section and inserts the necessary rows at the same time it does the other operations.

  15. #15
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macros: Data cleaning macros not producing expected outputes.

    I was already suspecting that, when typing in the rows from the OP's code. But consider it to be another method to insert rows.

  16. #16
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros: Data cleaning macros not producing expected outputes.

    Ok, here is the code I have so far. It addresses the issue you were having that rows with a blank column T were not being deleted. Also, notice that it is much more compact. That is the beauty of loops. It allows you to do repetative operations without listing them all out individually. You just have to set your variables and formulas correctly. This code block is a fairly large step from the last one I posted. Please respond with any questions.

    Please Login or Register  to view this content.

    I haven't looked at your formulas in Sheet1 yet. The reason the fixed references are changing is because you are deleting and inserting rows. Fixed references follow the cell they are fixed to. If cell $A$16 is moved up because a row above it was deleted, the reference will change to $A$15 (depending on the number of rows deleted). The same goes for if rows are inserted. Excel doesn't just blindly keep the reference at $A$16.

    I'll report back with either an uploaded workbook or suggested formulas to use.
    Last edited by Whizbang; 06-09-2011 at 08:59 AM.

  17. #17
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros: Data cleaning macros not producing expected outputes.

    Ok. Here is what I've cooked up in regards to Sheet1. I decided to make it simple and just use INDEX(). This allows you to fix the row and column numbers and ignore inserted and deleted rows and columns.

    Please review the attached workbook and respond with any questions.
    Attached Files Attached Files

  18. #18
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macros: Data cleaning macros not producing expected outputes.

    Please Login or Register  to view this content.
    or ?
    Please Login or Register  to view this content.

  19. #19
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros: Data cleaning macros not producing expected outputes.

    Quote Originally Posted by snb View Post
    Please Login or Register  to view this content.
    or ?
    Please Login or Register  to view this content.
    You know, I looked at my code several times, asking myself, "What would snb do?". I knew there was probably an easier way to do that without a loop, but I just couldn't see it.

    Thanks again for suggesting ways to improve my code.

  20. #20
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macros: Data cleaning macros not producing expected outputes.

    In this case you are cleaning up a copied/pasted webpage.
    If you use a webquery you can indicate which tables you want to be transferred. Probably it saves you a lot of 'cleaning' code.

  21. #21
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros: Data cleaning macros not producing expected outputes.

    @snb
    Yeah, I was tempted to go that route, but I wanted to show the original poster ways to improve his code to get the same result, but cleaner.

    @bertlogdi1
    If you want to see a procedure that would bypass the manual operation of copying and pasting from the webpage, please provide the URL for the website you are copying from. I don't have much experience in doing things with data from webpages, but I can at least get your started and other members of this forum can help finish the project.

  22. #22
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros: Data cleaning macros not producing expected outputes.

    @snb
    The last bit of code you provided causes an issue where other rows that have a blank column S are being deleted. In the OP's original workbooks, he copied the formula from S1 all the way down to row 500. In my code, I only copy that code to the rows that need to be evaluated in each section, leaving a lot of blanks. But I can take your code, and work it into the loop above and just change the "Columns(14)" bit to "Range("S" & lngStartRow + 1 & ":S" & lngStartRow + 21)". This then caused the issue where sometimes we tell it to delete 0 rows (becuase there might not be any blank cells in S). So, I had to re-add the On Error Resume Next.

    So, the final code is:
    Please Login or Register  to view this content.
    ******Edit****
    Nevermind. The .Replace isn't replacing the cells with "N" in them. The "N" is a result of a formula. Replace is looking at formulas and xlWhole. "N" is not the whole formula. If I change it to look at part, it returns all cells in that range, because they all have "N" as part of their formulas. I tried to change it to look at the values, but it doesn't look like that is an option with .Replace.
    Last edited by Whizbang; 06-09-2011 at 10:59 AM.

  23. #23
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros: Data cleaning macros not producing expected outputes.

    My code, as it stands now, is:

    Please Login or Register  to view this content.

  24. #24
    Registered User
    Join Date
    06-03-2011
    Location
    chertsey, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Macros: Data cleaning macros not producing expected outputes.

    I cannot thank you guys enough. The reason I am copying and pasting and then cleaning is because someone told me that there is no way to import javascript loaded data from websites. The website example: http://www.racingpost.com/greyhounds/card.sd

    The data is not in HTML format but java delivered. As such my only option is to copy and paste it. One thing that I cannot understand is that when I paste the main data into excel the number for each racer tend to hover above the rest of the data and cover some part of the racer's name. I have tried to remove all hyperlinks from the excel page but these numbers and some others tend to still float above the underlying data and cannot be deleted.

    If on the other hand I have been fed wrong information and it is indeed possible to parse these data from the website then I will be very happy if anyone can help out.

    Once again thanks to both of you for your wonderful help.


    Quote Originally Posted by snb View Post
    In this case you are cleaning up a copied/pasted webpage.
    If you use a webquery you can indicate which tables you want to be transferred. Probably it saves you a lot of 'cleaning' code.

  25. #25
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros: Data cleaning macros not producing expected outputes.

    You could try doing a pastespecial and paste is as text only. The numbers are actualy images that are embedded as part of your paste. You would need to right-click and "Cut" each one. There is probably a faster way to remove all embedded images, but nothing comes to mind. I don't usually have images in my workbooks, so I have limited experience in handling them on a large scale.

  26. #26
    Registered User
    Join Date
    06-03-2011
    Location
    chertsey, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Macros: Data cleaning macros not producing expected outputes.

    Hi Whizbang. First off, your code works like magic. The screen did not flash so things just happened!...magical! I thank you and snb very much.

    Now I might be pushing my luck but there are things I would have loved to see looked into or added. Firstly, there are the other one block of data per racer to add to the main data. Usually, I would add those data after the first macro. Now with this one macro will it not be best to add the various data to the ends of each racer before running the macro. If that is the case will this not produce the wrong outcome given that the blocks to be added are different lengths?

    Then I wiould have liked that the "m" in column C under "DIS" be removed so those boxes will for example read "380" rather than "380m". Also, it will be better if the bracket signs are removed from column D under "TRP" so one gets "6" rather than "[6]". Finally, in the "FIN" column which comes originally under column G, it will be nice to have only the numbers and no text so one gets "1" rather than "1st".

    I hope I am not asking for too much. On the issue of thewebsite, I have been told that the data cannot be imported directly. How true this is I do not know. I have provided the link in my other post for your use to explore the chance of helping me further. One other thing though is that I have been told thet excel has a way of using Data.Object aspect of MS 2.0 library to handle pasting such that if implemented, I will only copy the 7 data to clipboard and the macro will paste them appropriately and clean the data. I hope someone can help in this wise.

    All the same thanks to you guys for a splendid selfless help.
    Rgds.










    Quote Originally Posted by Whizbang View Post
    My code, as it stands now, is:

    Please Login or Register  to view this content.

  27. #27
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros: Data cleaning macros not producing expected outputes.

    Quote Originally Posted by bertlogdi1 View Post
    Firstly, there are the other one block of data per racer to add to the main data. Usually, I would add those data after the first macro. Now with this one macro will it not be best to add the various data to the ends of each racer before running the macro. If that is the case will this not produce the wrong outcome given that the blocks to be added are different lengths?
    Please clarify this. What data is being added? Walk me through the process as if it were entirely manual.

    Quote Originally Posted by bertlogdi1 View Post
    Then I wiould have liked that the "m" in column C under "DIS" be removed so those boxes will for example read "380" rather than "380m". Also, it will be better if the bracket signs are removed from column D under "TRP" so one gets "6" rather than "[6]". Finally, in the "FIN" column which comes originally under column G, it will be nice to have only the numbers and no text so one gets "1" rather than "1st".
    This is all very doable. I will add them to my code and report back.

    [QUOTE=bertlogdi1;2541753]On the issue of thewebsite, I have been told that the data cannot be imported directly. How true this is I do not know. I have provided the link in my other post for your use to explore the chance of helping me further. One other thing though is that I have been told thet excel has a way of using Data.Object aspect of MS 2.0 library to handle pasting such that if implemented, I will only copy the 7 data to clipboard and the macro will paste them appropriately and clean the data. I hope someone can help in this wise.QUOTE]
    I will look into Webqueries and Data.Object aspect of MS 2.0 library. Like I said before, I do not have much experience (practically none) with working from webpages. I'll at least be able to post a few promising links, however.

  28. #28
    Registered User
    Join Date
    06-03-2011
    Location
    chertsey, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Macros: Data cleaning macros not producing expected outputes.

    Hi Whizbang,
    Thanks again for your genorousity. This is how it happens manually:
    1- I go to www.racingpost.com
    2- I select the greyhound tab
    3- I select the card section from the drop-down.
    4- I click one of the races I am interested in
    5- I scrol down to the bottom where the picks are and copy from there to the top stopping at the time of the event.
    6- Then I copy the highlighted data.
    7- Next, I will click on each individual entrant and from the pop-up, copy from the 6th till I get enough "A" races including the number of "A" races in the earlier 5 on the already copied data. Now this is where the variation occurs as some may have 5 "A"s already meaning they need only one race copied while others will need 6 races copied
    8- Then off course there are those that do not have any extra A races to add nor do they have enough A races already. These ones will not get any data added instead the macro is expected to copy the first "A" race they have to make up the required 6.
    9- For those that I have copied data for, they are those that will now require the addition of data.
    I hope this is clear. If not please re-ask.
    Regards.

    [QUOTE=Whizbang;2542080]Please clarify this. What data is being added? Walk me through the process as if it were entirely manual.


    This is all very doable. I will add them to my code and report back.

    Quote Originally Posted by bertlogdi1 View Post
    On the issue of thewebsite, I have been told that the data cannot be imported directly. How true this is I do not know. I have provided the link in my other post for your use to explore the chance of helping me further. One other thing though is that I have been told thet excel has a way of using Data.Object aspect of MS 2.0 library to handle pasting such that if implemented, I will only copy the 7 data to clipboard and the macro will paste them appropriately and clean the data. I hope someone can help in this wise.QUOTE]
    I will look into Webqueries and Data.Object aspect of MS 2.0 library. Like I said before, I do not have much experience (practically none) with working from webpages. I'll at least be able to post a few promising links, however.

  29. #29
    Registered User
    Join Date
    06-03-2011
    Location
    chertsey, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Macros: Data cleaning macros not producing expected outputes.

    Thanks.


    This is all very doable. I will add them to my code and report back.[/QUOTE]

  30. #30
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros: Data cleaning macros not producing expected outputes.

    As promised, here is the code that handles the remaining cleanup:

    Please Login or Register  to view this content.
    Quote Originally Posted by bertlogdi1
    7- Next, I will click on each individual entrant and from the pop-up, copy from the 6th till I get enough "A" races including the number of "A" races in the earlier 5 on the already copied data. Now this is where the variation occurs as some may have 5 "A"s already meaning they need only one race copied while others will need 6 races copied
    This is what you mean by a process you previously did between cleaner 1 and cleaner 2, correct?
    Quote Originally Posted by bertlogdi1
    8- Then off course there are those that do not have any extra A races to add nor do they have enough A races already. These ones will not get any data added instead the macro is expected to copy the first "A" race they have to make up the required 6.
    This is handled by the macro already, correct?
    Quote Originally Posted by bertlogdi1
    9- For those that I have copied data for, they are those that will now require the addition of data.
    What data is being added?
    Last edited by Whizbang; 06-16-2011 at 09:08 AM.

  31. #31
    Registered User
    Join Date
    06-03-2011
    Location
    chertsey, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Macros: Data cleaning macros not producing expected outputes.

    This is what you mean by a process you previously did between cleaner 1 and cleaner 2, correct
    ?

    Yes indeed. Thanks for understanding.

    This is handled by the macro already, correct?
    Yes and thanks again.

    What data is being added?
    Same as first as above so no new addition. I will now go on and try it out and report back later. Rgds.

  32. #32
    Registered User
    Join Date
    06-03-2011
    Location
    chertsey, england
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Macros: Data cleaning macros not producing expected outputes.

    Hi Whizbang,
    Once again thank you. I have tried the code and it runs fine (T and TT attached). However here are the remaining issues:
    1- The code needs to be broken into two for now as I need to add the extra data copied for the entrants just after the point where the macro adds 15 extra rows.

    2- The break point should be such that the addition of the rows occurs before the copying of any columns e.g. column U.

    3- Is there a way to stop sheet one from changing the formula in the cells while the macro runs? That is can I have sheet one in an independent workbook which I only open and link to the worksheet that contains the macro such that the formulas will copy the right cells?

    Thanks.
    Attached Files Attached Files

+ 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