Trying to paste values - out of memory?

theta

Well-known Member
Joined
Jun 9, 2009
Messages
960
Hi. When I manually select Table1 (range a1:cc100000) I can paste values no problem

When trying to macro it, gives me error 7 ?

I have tried putting break points in etc, debugged. Always crashes out.

Then I can select the data and do it manually, but breaks when in macro

Thoughts?

If not I could try doing cells(nLastRow,1) paste values and cycle this along for range(1, nLastCol) ? Then do it for each column (paste values) instead of the whole range?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Works with smaller files?

Also, when importing the XML manually it is fine, but when importing with macro...the header and first row are highlighted?

First part of code (import)

Code:
ublic Sub XMLfileImport()
'Purpose: Import XML data in a new workbbook. Prepare data to be used for HUB invoicing
    Dim owb As Workbook, oWS As Worksheet, oRng As Range, ofltRange As Range
    Dim sXMLFile As Variant, sXLfile As String
    Dim nLastRow As Long, nLastCol As Long, nTAPCol As Long, r As Long, c As Long, i As Long
    Dim nm As Name
    Dim nSchemaNo As Long, nMaxPMN As Long, nValidSchemaFields As Long
    Dim sHeader As String, sPMN As String, sHPMN As String
    Dim aSchemas()
    
    On Error GoTo ErrHandler
    Call BeforeMacros
    
    ' Open XML file --------------------------------------------------------------------
    sXMLFile = Application.GetOpenFilename(FileFilter:="XML Files (*.xml), *.xml", Title:="Please select XML file")
    If sXMLFile = False Then GoTo TheEnd 'Esc pressed
    
    With frmWait
        .Show vbModeless
        .lbxInfo.AddItem "Please wait during XML file import ..."
        .Repaint
    End With
    
    Application.DisplayAlerts = False
    Workbooks.OpenXML Filename:=sXMLFile, loadoption:=xlXmlLoadImportToList
    Application.DisplayAlerts = True
    frmWait.lbxInfo.RemoveItem 0
    frmWait.lbxInfo.AddItem "XML data imported"

The second part is where the crash happens

Code:
    ' Store numbers as text etc --------------------------------------------------------
    With oWS
       .UsedRange.Value = oWS.UsedRange.Value 'prevent numbers stored as text
       .Name = "XML Data"
       .Tab.Color = 49407
       .AutoFilterMode = False
       .Cells(1, nLastCol).AutoFilter
       .Range("A2").Select 'for Freeze Panes
    End With
    ActiveWindow.FreezePanes = True
    frmWait.lbxInfo.AddItem "Numbers stored as values"
    frmWait.Repaint
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,865
Members
452,948
Latest member
UsmanAli786

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