Hi,
To be honest, I am unsure what has happened overnight, as this was working! Now however, I am getting 'runtime error 9 -subscript out of range'. Bizarre, even in old versions of this file that previously worked, they no longer do. Please forgive the use of "select" or "activesheet", the code was written when I knew even less than I do now!
To explain, the following is the relevant snippet from reels of vba. I am using VBA to build a costing spreadsheet that places items from a table on a different sheet ("Data"), under relevant headings on another sheet. It's slow but it has previously trundled through moving DataBodyRange members based on a columns heading match (cell.value from previous sheet) quite happily.
Now however I get out of range. I have tried increasing the specificity and checking table / sheet names but I still keep getting the same thing. Any hints on what excel might be up to and what I need to change would be greatly appreciated.
Cheers
Rohan
ps. I think my set rangename line is actually redundant as I don't use the name elsewhere. I think it's an artifact
To be honest, I am unsure what has happened overnight, as this was working! Now however, I am getting 'runtime error 9 -subscript out of range'. Bizarre, even in old versions of this file that previously worked, they no longer do. Please forgive the use of "select" or "activesheet", the code was written when I knew even less than I do now!
To explain, the following is the relevant snippet from reels of vba. I am using VBA to build a costing spreadsheet that places items from a table on a different sheet ("Data"), under relevant headings on another sheet. It's slow but it has previously trundled through moving DataBodyRange members based on a columns heading match (cell.value from previous sheet) quite happily.
Now however I get out of range. I have tried increasing the specificity and checking table / sheet names but I still keep getting the same thing. Any hints on what excel might be up to and what I need to change would be greatly appreciated.
Cheers
Rohan
ps. I think my set rangename line is actually redundant as I don't use the name elsewhere. I think it's an artifact
VBA Code:
For Each cell In RngA
If cell.Style = "Heading 4" Then
Sheets("Data").Select
On Error Resume Next
'Copy only cells with values from under the appropriate heading (Cell.Value)
Set rangename = ActiveSheet.ListObjects("System_Section_Content").listcolumns(cell).Value
With ActiveSheet.ListObjects("System_Section_Content").listcolumns(cell.Value).DataBodyRange
On Error Resume Next
Set rngChange = .SpecialCells(xlCellTypeConstants)
rngChange.Copy
On Error GoTo 0
End With