Mr. Emamuddin, I'd be glad to help you with this.I think there's quite a bit I can do to streamline this macro.I've spent quite some time trying to create a sample file to try to follow what your macro does,but since I don't know what your data actually represents, I'm having trouble following. for one thing, I'd recommend you move the IF() test in your nested loops.Executing:For i = 1 To lr For j = 1 To mydcnt For k = 1 To mycellnum For m = 1 To 6 For n = 3 To 9 THEN testing to see if the value in the "X" column is the required date means that if you have 1000 records, 10 of which are the current date, thenyou will be checking EACH row 21,600 times, and since you're processing 1000 rows, that's over 21 MILLION IF() tests. Even when you FIND a row with a matching date, you're STILL duplicating it 21,600 times! So, I'd put the IF() test right after the For i = 1 To lrline so that it skips the other tests if the date doesn't match. Could you send me a copy of your file so that I can try to follow what the macro does? Paul----------------------------------------- “Do all the good you can, By all the means you can, In all the ways you can, In all the places you can, At all the times you can, To all the people you can, As long as ever you can.” - John Wesley -----------------------------------------
On Thursday, August 4, 2016 5:45 AM, Emamuddin Shah <emt...@gmail.com> wrote: Hello All, iam an intermediate user of VBA i love to automate, iam struck in on of my code when iam using to fetch data from my excel sheet based on todays date and same thing copied after last rows. it is working but in last all copied cells goes empty.. here is my code please suggest. Sub todayinterview() Dim lr As Long Dim myrow() As Variant Dim mydata() As Variant With ActiveSheet lr = .Cells(.Rows.count, "A").End(xlUp).Row End With Cells(lr + 2, 3) = "=countif(x:x,Today())" ' (this is to count how many occurrence of today's date) mydcnt = Cells(lr + 2, 3).Value mycellnum = mydcnt * 6 ' if there is 2 rows with todays date and i need data from 6 coloumns than mydcnt*6 ReDim myrow(mydcnt) ReDim mydata(mycellnum) Dim mycol(1 To 6) As Variant 'For a = 1 To 6 ' this is to get only specific data from row mycol(1) = 3 mycol(2) = 4 mycol(3) = 5 mycol(4) = 6 mycol(5) = 24 mycol(6) = 25 '(also please help to cycle this array after last number reached) For i = 1 To lr For j = 1 To mydcnt For k = 1 To mycellnum For m = 1 To 6 For n = 3 To 9 If Cells(i, 24) = Date Then myrow(j) = Cells(i, 24).Row 'MsgBox myrow(j) mydata(k) = Cells(myrow(j), mycol(m)) Cells(lr + 7, n) = mydata(k) Cells(lr + 3 + j, 3) = myrow(j) 'MsgBox mydata(k) End If Next n Next m Next k Next j Next i 'For n = 1 To mycellnum 'Cells(lr + 7, n) = mydata(n) 'Next n MsgBox mydata(4) End Sub-- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at https://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/d/optout. -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at https://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/d/optout.