Macro to appendend results from one sheet and append after last row of another worksh

khanaran

Member
HI

I would like to improve on a macro that I have.

The macro is able to copy data from worksheet called archive and append it to end of last row of worksheet skips

After the results are append , I would like the formula that will abe above to be copied to the appended row. end of Row J to row CE

I attach my sheet hereto

https://www.mediafire.com/?qpxcuk62lcbdvg7

Thanking you in anticipation for all help that I will receive

Regards

Raj
 

Frank

Member
Well one or two things wrong here making your macro unusable as supplied.

Your Macro2 for some reason was copying range A6 to E6 on the archive page. That wasn't a complete result, should be A6 to H6 ?

Secondly your two sets of results on the two pages start on different rows, Archive, row 6 but Skips row 4. You used a variable LASTROW to calculate how far down to paste a new result on the skip page, but it was 'archives' lastrow not 'skips' lastrow so you were 2 rows out positioning it. You hadnt begun to tackle the copying of formulas on the Skips page.

Check out selection.offset(-1,9) to choose a starting point 9 columns to the right of where you are now in col A (skip sheet) and one row above. (where the formulas begin and select the cell). Then copy them in vba (check out the resize command in vba to select all the formulas first).
selection.offset(1,0) to position them on the row below - ready to paste - same row you started off from.
Some maths needed to change draw number 1 (copied from archive sheet) to one more than previous result.

https://www.mediafire.com/?374bqkp745044ok

Hope this is what you wanted.
 

khanaran

Member
Hi Frank

Thank you once again for the help

This is what I was looking for and its working like a dream

Thank you very much for the explanations as well

Regards

raj
 

jack

Member
http://www.mediafire.com/file/qbcyq093cxl31re/QUINA_CYRIL.xlsx
Hello, please frank, my lottery is 80/5
* To separate the initial digit and the final digit and to see the leaps of the digits and not of the numbers of the last one for the next one,
Objective = vertically view each digit jumps from 0 to 9
 

khanaran

Member
Hi Frank

I now have my skips as you suggested the latest results at the end in place of the beginning

The macro is working brilliantly and is appending the data as requested.

I thank you very much for the macro.

I discovered that the first ball out is indeed a very good pointer for the next result.


I set up the frequency for all the balls from 1 to 5 as well as the pb from 1 to 20.

I further created a frequency table for the first ball out and added the last skip from the skip table for each ball excluding the pb.

My macro1 copies and updates but its not doing it correctly I do realise there is sumthing wrong with my formula maybe its the absolute value thats causing it.

I would appreciate you taking a look at it and to please correct where I have gone wrong for which I thank you .

Also can you please give me some suggestions on how to make the page like how you do whenever you design a page, mine is looking very unprofessional.

here is the link for my sheet

http://www.mediafire.com/file/qpxcuk62lcbdvg7/pb+rsa.xlsm

Thank you so kindly

Raj
 

Frank

Member
Before we get to the macro, you need to know about other errors. On the Archive sheet you had the following formula in cell AH2 =COUNTIF($C6:$C3000,AG2)
You copied this down the column but the test range (your main balls table) was moving down also with it. In cell AH3 this became =COUNTIF($C7:$C3001,AG3). By the time you got to AH8 your formula was =COUNTIF($C12::$C3006,AG8). The top part of your results table are not now included.

in AH2 it should be =COUNTIF($C$6:$C3000,AG2) to anchor the top row to row 6. so when copied down it is still anchored to $C$6. I have corrected this for you. I let the bottom boundary drift as theres nothing below the range to corrupt your results.

You did not have the last draw number (765 ) in. This meant that cell A1 (=max of col C) is not recording how many draws. You need this, see later.

If you know how many draws you can create a checksum.Checksums make sure that when you use countif or frequency formulas on tables, that you havent made a mistake.


Adding up all your countif results (Col AH) should equal how many draws. If it does equal how many draws (cell A1) you havent made a mistake with your countifs. But you MUST have the draw number up to date.

I don't like your frequency/probability table, youve made a major error there. Your formula in cell V3 is =COUNTIF($C:$G,V2) Using whole column references.

This is very lazy!! and causes a host of problems. You are saying .. count EVERYTHING between C1 and H1048576

This means you've counted the latest result TWICE! Youve copied this formula to all the other ball numbers making the same mistake for them all. To avoid errors BE SPECIFIC where your table begins. it begins in cell $C$6 the $ signs are important because your other balls are on different rows and columns but you must anchor the top left of your table to $C$6, so your formula in cell V3 should be =COUNTIF($C$6:$G10000,V2). note Ive set an upper bound to how many rows it checks, 10,000 . Why waste time and energy checking the other 990,000 rows? Had you set up a checksum for your frequency counts you'd have seen the error. The sum of all main ball frequencies should equal how many balls have ever been drawn = (how many draws ) x 5. if it doesn't you've made an error! I have not corrected your frequency formulas , ill leave that to you, but Ive set up a checksum so you'll know if you get it
right!

Macro2 you comitted a cardinal sin. You copied a "live" table with formulas linking to other sheets, pasted it elsewhere with the live fromula links still live then sorted it. Obviously after the sort, the formulas in the sorted table updated and put the original values back in corresponding to the whatever the formulas said they should do, but whilst in different positions. Or to be precise,that is it would have done, had you included the last column (skips) in the sort which link to a different page, but you didnt. You left that part out of the sort so it was showing the skips of balls 1,2,3,4 in order despite the fact that the ball numbers were now jumbled up after a sort. I suggest when you copy a table for sorting, you PASTE VALUES but make sure you include ALL the columns you want to move with the sort. I have corrected this. https://www.mediafire.com/?khdsk50l230ms4c

As for looking professional, its coming along nicely, but you must focus on accuracy before looks. Use checksums, always click in the formula bar after youve written a formula, to see which cells Excel outlines, showing you what cells or ranges your formula acts on. The rest is just time and confidence, it takes years not months. Good luck!
 

khanaran

Member
Hi Frank

Thank you for pointing out my mistakes and for the corrections.

Thanx once again for the note on checksum. I am learning a great deal here and must thank you for that.

OK I fixed the freq table with your advice and the checksum's showed ok so it was great learning this.

Now all checks ok with the draws.

Thank you once again

Should I upload the file
REgards

raj
 

Frank

Member
Jack, this thread has nothing to do with Brasil 80/5. You have been here long enough to understand that forums have RULES.

RULE NO 1 DO NOT POST OFF TOPIC IN SOMEONE ELSES THREAD.


You disrupt the flow of conversation about the topic being discussed by throwing irrelevant, distracting, unrelated nonsense into someone elses discussion.

You have a very very bad habit of trying to hijack someone elses conversation to draw them away from their discussion onto your pet subject, digit juggling.

I wish to make it absolutely crystal clear that I WILL NEVER EVER RESPOND to you when you hijack a thread, when you post off topic or when you make MULTIPLE POSTS without waiting for any response. Nor will I respond to any of your posts addressed to me by name unless currently in a conversation. By doing this you give everyone else an excuse to ignore you and reduce your chances of a reply.

I am not the first person to speak to you about your behaviour. PAB had to have words with you told you exactly how you should conduct yourself a few years ago just before he left the forum. You chose to ignore that advice. Ignore me at your peril Jack, as I'm not as polite as PAB was.

RULE NO 2
Do not post a sprat to catch a mackerel. In other words you ask for something easy whilst having a hidden agenda to make more demands of increasing complexity afterwards having reeled in your 'victim' . I can smell them a mile off, so don't even try it! Be honest upfront about what you really want.

You should realise that as I approach my 70'th birthday I have other priorities in my life, I stopped burning the midnight oil on other peoples spreadsheets many years ago and am in semi retirement from lottery research, so I pick and choose what to get involved with and what to leave to others. So don't stalk me, I will ignore you.
 

jack

Member
Hello, I'm not chasing anyone, just changed the size of my lottery 80/5
Excuse me. Just changed the lottery (size) the intention is to help
 

Frank

Member
How is trying to get me involved with digit juggling in your 89/5 lottery helping Khanaran with his Macro to append results. EXPLAIN
 

jack

Member
Hello, FRANK it's not juggling, it just changes the size of the lottery to 80/5, it's all the same,
So I put it in the same post, it's all the same as what kharam requests in the macro. Just change
The size of the lottery, to 80/5, because I found the system good, to do the same but in the 80/5
 

khanaran

Member
Hi Frank

I attach my amended file and the checksum is working great with all the freq tables.

I have just obne problem:-

after updating the file with the latest results, it copies and runs macro 2 without a hitch.

How can I get it to return to archives after running macro 2

Secondly, it drops the row in archive but I have manually copy down the numbers from column A.

I tried with a dim statement and set range . it works ok but then it runs macro2 but it does execute properly so I remove the dim and set comman and it works on

How can I change the update macro that after it updates and runs macro 2 it returns and copies the column A by one row and increases the number by 1 then the checksum works.

Also is there a way to amend macro 1 to firstly record the last skip for in AI of archives. before it copies and sorts the table

http://www.mediafire.com/file/7xvknvjee41mlz1/pb+rsa+master.xlsThank you

Raj
 

Frank

Member
Hi Frank

I attach my amended file and the checksum is working great with all the freq tables.

I have just obne problem:-

after updating the file with the latest results, it copies and runs macro 2 without a hitch.

How can I get it to return to archives after running macro 2

Secondly, it drops the row in archive but I have manually copy down the numbers from column A.

I tried with a dim statement and set range . it works ok but then it runs macro2 but it does execute properly so I remove the dim and set comman and it works on

How can I change the update macro that after it updates and runs macro 2 it returns and copies the column A by one row and increases the number by 1 then the checksum works.

Also is there a way to amend macro 1 to firstly record the last skip for in AI of archives. before it copies and sorts the table

http://www.mediafire.com/file/7xvknvjee41mlz1/pb+rsa+master.xlsThank you

Raj


Raj

Well you need first to get both sheets to match the number of draws in the two tables. The copy I downloaded was out of step by one draw. You need to first make sure they are BOTH on draw 765 and all rows filled in as a starting point.

Then you need to amend macro 2 at the end to tell it to go to the archive sheet. Then tell it to select cell A5. Whilst that cell is selected you can use the OFFSET command to write to the cell 765 plus 1 steps below (thats cell A1 value plus 1). Tell it to write in that cell the value of cell A1 plus 1. I have done this to prove it works but im not uploading it, you can do this yourself.

This is what you need to add:- to macro 2

'on the end of macro 2
Sheets("archive").Select
Range("A5").Select 'directly above the draw number 1
ActiveCell.Offset(Range("A1").Value + 1, 0) = Range("A1").Value + 1 ' next empty number is one more


Thats it. Job done.

I do not understand what you are asking here:-
Also is there a way to amend macro 1 to firstly record the last skip for in AI of archives. before it copies and sorts the table.

This is not making sense to me. By by copying and pasting AG2:AJ46 you are preserving that information prior to the sort, until the next draw. column AI is part of that preserved information. You have lost me here. What exactly are you wanting to save that is not already saved, where do you want to save it and how long for ? ?
 

khanaran

Member
Hi Frank

Thank you so much for the advice and the code

I really appreciate that you encourage me to fix my programme using your advice. I appreciate this since I learn whilst I am updating my spreadsheet.

The sheets update brilliantly now.

The second question I do apologise for not making my self clear.

After updating the results and running macro2 the skips sheet gets updated with the latest result.

On my archive sheet column AJ2 to AJ50 has a link to the skip sheet. After updating, can this column be updated automatically. I have to find the last formula and replace by adding one to the formula in order to read the latest skip.

Looking forward to a way to amend the search and replace of column Aj2 to aj50 by adding one to the last result


Regards

raj
 

Frank

Member
Well Raj, that's because youve got the wrong formula in the cells of column AJ. You appear to have 'fixed' the row that the formula is looking at by using dollar signs in your formulas, locking them to a row. If you want them to automatically update, then you need a way of changing the row number according to how many draws are in your database. It's time to use a named range to help us out.
You always know how many draws are in your database because you are counting them (in cell A1) so why not use this information ?

I suggest you make (on the archive sheet) cell A1 into a named range. Name it (say) maxdraw. The quick way of naming a range is to first select it, then in the 'name box' which should be directly above cell A1, type in maxdraw and press 'enter'. There are other ways using 'name manager' to name, amend or delete a named range which I suggest you look into.

From now on 'maxdraw' will be how far to look down the skips sheet from row 3 to find the latest skip. So your new formula will use the offset function and reference row 3 counting down maxdraw rows.

in cell AJ2 your formula becomes =OFFSET(skips!$Q$3,maxdraw,0) thats maxdraw cells down, 0 cells to the right.

AJ3 formula is =OFFSET(skips!$R$3,maxdraw,0)
AJ4 formula is =OFFSET(skips!$S$3,maxdraw,0)

you can see the pattern, manually increase the letter (column reference for each) Heres a tip, copy the top formula down, even though doing this gives the wrong result. Then the formula you get is easier to edit manually as you go down.

Good luck!
 

khanaran

Member
Hi Frank

Thank you for sorting out my spreadsheet

I really like the way you explain on how to remedy all the problems and I appreciate your time and manne in which you teach how to solve problems.

I am learning a great deal from you

Thank you once again

My spreadsheet is now running perfectly
 

Sidebar

Top