VBA not working in office 2010

YyY_PLM

New Member
Joined
Mar 20, 2022
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi all,
I wrote a code in office 365 and it work fine when I tried to run it on office 2010 the excel is not responding
code attached

Rich (BB code):
Sub RectangleRoundedCorners1_Click()
 Dim FileToOpen As Variant
    Dim OpenBook As Workbook


    
    Application.ScreenUpdating = False
    FileToOpen = Application.GetOpenFilename(Title:="Browse for Main_0.log", FileFilter:="Excel Files (*.log*),*log*")
    If FileToOpen = "False" Then
    Exit Sub
    End If
        Set OpenBook = Application.Workbooks.Open(FileToOpen)
        OpenBook.Sheets(1).Range("A1:B99999").Copy
        ThisWorkbook.Worksheets("Main_0").Range("A1").PasteSpecial xlPasteValues
        Application.CutCopyMode = False
        OpenBook.Close False
        
        'Y counts from Stage'
        
            Range("N2").Select
    ActiveCell.FormulaR1C1 = _
        "=IFERROR(LEFT(MID(RC[-13],FIND("" Y :"", RC[-13])+4,LEN(RC[-13])),FIND(""("",MID(RC[-13],FIND("" Y :"",RC[-13])+4,LEN(RC[-13])))-1),"""")"
    Range("N2").Select
       Selection.AutoFill Destination:=Range("N2:N150000"), Type:=xlFillDefault
    Range("N2:N150000").Select
    
        
        Range("O2").Select
    ActiveCell.FormulaR1C1 = _
        "=IFERROR(LEFT(MID(RC[-14],FIND(""Y laser :"",RC[-14])+9,LEN(RC[-14])),FIND("","",MID(RC[-14],FIND(""Y laser :"",RC[-14])+9,LEN(RC[-14])))-1),"""")"
    Range("O2").Select
    Selection.AutoFill Destination:=Range("O2:O150000")
    Range("O2:O150000").Select
    
       Range("P2").Select
    ActiveCell.FormulaR1C1 = "=ROW(RC[-15])"
    Range("P2").Select
    Selection.AutoFill Destination:=Range("P2:P150000")
    Range("P2:P150000").Select
    
    
        Columns("N:N").Select
    Selection.AutoFilter
    ActiveSheet.Range("$N$1:$N$100162").AutoFilter Field:=1, Criteria1:="<>", Operator:=xlAnd, Criteria2:="<>#VALUE!"
    
    With Range("P2:P150000")
           row20 = Evaluate("AGGREGATE(14,7," & .Address & ",20)")
         row1 = Evaluate("AGGREGATE(14,7," & .Address & ",1)")
           ActiveSheet.Range(Range("N" & row20), Range("O" & row1)).SpecialCells(xlCellTypeVisible).Copy Destination:=ThisWorkbook.Worksheets("Y Laser Factor").Range("B4")
  
    End With
    
     Worksheets("Y Laser Factor").Range("O2").Formula = "=IFERROR(Average(D4:D23),"""")"
    
    Application.ScreenUpdating = True
    Worksheets(ActiveSheet.Index - 1).Select
    Range("O2").Select
    Selection.Copy
    Range("D24").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
End Sub
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
I would step through the code line by line using F8 to see where it hangs. I am not sure that the AGGREGATE function is supported in 2010 but i am not 100% on that.
 
Upvote 0
"Not responding"

Can you tell which line of code causes this? Is there an error message?
 
Upvote 0
Rich (BB code):
ThisWorkbook.Worksheets("Main_0").Range("A1").PasteSpecial xlPasteValues

its try to paste it and failed, sheet main_0 is exists and work fine on office 365
 
Upvote 0
Just in case it is the size of the copy area that is causing you the issue do you want to try replacing that 1 line with this ?
VBA Code:
        Dim rngToCopy As Range, rngDest As Range
        Set rngToCopy = OpenBook.Sheets(1).Range("A1:B99999")
        Set rngDest = ThisWorkbook.Worksheets("Main_0").Range("A1").Resize(rngToCopy.Rows.Count, rngToCopy.Columns.Count)
        rngDest.Value = rngToCopy.Value
 
Upvote 0
ThisWorkbook.Worksheets("Main_0").Range("A1").Value = OpenBook.Sheets(1).Range("A1:B99999").Value
 
Upvote 0
Sorry, it's hard to get it right on my phone. Try this:

VBA Code:
ThisWorkbook.Worksheets("Main_0").Range("A1:B99999").Value = OpenBook.Sheets(1).Range("A1:B99999").Value

This way is quicker than using the clipboard.
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,100
Members
452,301
Latest member
QualityAssurance

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top