+ Reply to Thread
Results 1 to 11 of 11

Run time error 7. Out of memory error to correct

  1. #1
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Run time error 7. Out of memory error to correct

    Hello code experts
    I am trying to additional headings to KA sheet and get the data below the headings with the help of formulas in a code. I got the headings right but I am not able to print the formulas under the headings and I am getting run time erro 7. Can someone please correct the code to avoid the error. I also need to correct one line of code which is not being accepted FormulasArray(4) .

    Thanks in advance.
    Attached Files Attached Files
    Last edited by RAJESH SHAH; 01-18-2023 at 09:25 AM. Reason: #Solved by beyond excel

  2. #2
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: Run time error 7. Out of memory error to correct

    Due to no response, which is very rare, from the group I have shared the query with other forum.
    https://forum.ozgrid.com/forum/index...s-with-a-code/

  3. #3
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Run time error 7. Out of memory error to correct

    1) With your current process:
    try below code:
    PHP Code: 
    Option Explicit

    Sub GetFormulas
    ()
    Dim FormulasArray()         As Variant
    Dim LastRowKAB2B            
    As Long
    Dim i
    &
    LastRowKAB2B 5925 ' last row
    ReDim FormulasArray(1 To 5)
    '
    =VLOOKUP(Z5,'Extract B2B'!$Q$2:$Q,1,0)
        
    FormulasArray(1) = "=VLOOKUP($Z5,'Extract B2B'!$Q$2:$QLastRowKAB2B ",1,0)"                                        ' Formula for column D of 'Extract B2B'
    '
    =SUMIF('Extract B2B'!$Q$2:$Q$9329,W5,'Extract B2B'!$I$2:$I$9329)/COUNTIF('Extract B2B'!$Q$2:$Q$9329,KA!W5)
        
    FormulasArray(2) = "=SUMIFS('Extract B2B'!$Q:$Q,$W5,'Extract B2B'!$I:$I)/COUNTIF('Extract B2B'!$Q:$Q,$W5)"         ' Formula for column X
    '
    =X5-E5
        FormulasArray
    (3) = "=$X5-$E5" ' Formula for column Y
    '
    to correct =A5&" | "&C5
        FormulasArray
    (4) = "=$A5& "" | "" & $C5"  ' Formula for column Z
    '
    =IFERROR(IF(AND(B2>=-1,Y5<=1),"Matched",""),"Not Appearing")
        
    FormulasArray(5) = "=IFERROR(IF(AND($B2>=-1,$Y5<=1),""Matched"",""""),""Not Appearing"")"                                       ' Formula for column C of 'Extract B2B'
    '
    to correct
    For 1 To 5
       Sheets
    ("KA").Cells(522 i).Value FormulasArray(i)
    Next
    End Sub 
    2) I dont know for sure what are you trying to do, but I am for sure that there are proper way to archive the results, instead of trying to create header combination to get columns combination
    If you are willing to upgrade it, try to remove all helper columns/ header, then manual input what is the expected outcome, then upload file again.
    Quang PT

  4. #4
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: Run time error 7. Out of memory error to correct

    bebo. I got the formulas in KA right. I need to resize the columns with formula with column A. I thought this line will fill the rows below but it is not. Maybe I didn't understand that line.
    Please Login or Register  to view this content.
    I will try to create the same for Extract B2B but still the formulas columns need to be resized with column A.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: Run time error 7. Out of memory error to correct

    Sorry. Shared the wrong workbook. This is the updated one.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: Run time error 7. Out of memory error to correct

    Can you please change this line LastRowKAB2B = 5925 as there will be different rows in different data.?
    something like LastRow = Sheets("KA").Range("A" & Rows.Count).End(xlUp).Row
    It is a line from some other application and the range needs to be corrected.

  7. #7
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: Run time error 7. Out of memory error to correct

    I edited your code and did the same with the Extract B2B sheet and got the headings correct. But I am not getting the formulas.
    Maybe this line needs editing. I was not able to edit as I didn't understand that line.
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: Run time error 7. Out of memory error to correct

    Quote Originally Posted by bebo021999 View Post
    1) With your current process:
    try below code:
    PHP Code: 
    Option Explicit

    Sub GetFormulas
    ()
    Dim FormulasArray()         As Variant
    Dim LastRowKAB2B            
    As Long
    Dim i
    &
    LastRowKAB2B 5925 ' last row
    ReDim FormulasArray(1 To 5)
    '
    =VLOOKUP(Z5,'Extract B2B'!$Q$2:$Q,1,0)
        
    FormulasArray(1) = "=VLOOKUP($Z5,'Extract B2B'!$Q$2:$QLastRowKAB2B ",1,0)"                                        ' Formula for column D of 'Extract B2B'
    '
    =SUMIF('Extract B2B'!$Q$2:$Q$9329,W5,'Extract B2B'!$I$2:$I$9329)/COUNTIF('Extract B2B'!$Q$2:$Q$9329,KA!W5)
        
    FormulasArray(2) = "=SUMIFS('Extract B2B'!$Q:$Q,$W5,'Extract B2B'!$I:$I)/COUNTIF('Extract B2B'!$Q:$Q,$W5)"         ' Formula for column X
    '
    =X5-E5
        FormulasArray
    (3) = "=$X5-$E5" ' Formula for column Y
    '
    to correct =A5&" | "&C5
        FormulasArray
    (4) = "=$A5& "" | "" & $C5"  ' Formula for column Z
    '
    =IFERROR(IF(AND(B2>=-1,Y5<=1),"Matched",""),"Not Appearing")
        
    FormulasArray(5) = "=IFERROR(IF(AND($B2>=-1,$Y5<=1),""Matched"",""""),""Not Appearing"")"                                       ' Formula for column C of 'Extract B2B'
    '
    to correct
    For 1 To 5
       Sheets
    ("KA").Cells(522 i).Value FormulasArray(i)
    Next
    End Sub 
    2) I dont know for sure what are you trying to do, but I am for sure that there are proper way to archive the results, instead of trying to create header combination to get columns combination
    If you are willing to upgrade it, try to remove all helper columns/ header, then manual input what is the expected outcome, then upload file again.
    You were right bebo. I need to enter the headings manually each time and then run the code. After spending the whole day, I kept getting errors and was not able to solve the issue. Maybe tomorrow hopefully I will try from the beginning once again and get the correct result.
    Thanks Bebo.

  9. #9
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Run time error 7. Out of memory error to correct

    Hello.
    Looking at this subject from another point of view, it seems to me that it is more efficient if formulas are not used: would you see it?...
    Attached Files Attached Files
    You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped you.

  10. #10
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: Run time error 7. Out of memory error to correct

    beyond excel. Excellent code. Wish I could understand the code as it would help me to edit whenever and where ever necessary. Actually, as I am not a so expert coder, I create new applications referring the comments.
    Thank you very much for your time and especially the code. Now I have some extra work to do that is understand the code.
    Thanks once again beyond excel.

  11. #11
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Run time error 7. Out of memory error to correct

    Thanks for the +rep, @RAJESH SHAH.

+ 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] Run-Time error '7' Out of Memory
    By smciesl2 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-24-2014, 01:50 PM
  2. [SOLVED] Run-time error '7': Out of memory
    By jitte in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-10-2013, 06:14 AM
  3. Run Time error 7 - out of memory
    By sfw1973 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-25-2013, 11:55 AM
  4. [SOLVED] Run-time error 7: out of memory
    By gandrea in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-06-2012, 08:16 PM
  5. [SOLVED] Run-time error 7 out of memory vba
    By Jovica in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-19-2012, 09:08 AM
  6. Run-time error 7 out of memory vba
    By Macro1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2010, 09:42 AM
  7. Run-time error '7': Out of memory
    By rpollard001 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-11-2006, 02:15 AM

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