dcunningham
Board Regular
- Joined
- Jul 14, 2015
- Messages
- 58
Hello All,
I'm trying to copy a range of values from one sheet to another, and then filter out any NA() errors. So far, I have the following bit of code:
This works, sort of. The issue is it's a one and done sort of deal. The range being copied is the result of some calculations on a changing query of a database which determine whether or not I want the values to be copied (returning an NA() code if I want them excluded). The way I'm filtering the NA() codes is by filtering column A to just the NA() values and deleting those rows. The deleting of the rows also deletes the merging of the cells that I have, with A:D being merged and E:H being merged from row 9 down to row 2553. The same number of cells are merged in the Calculations sheet, and for the same number of rows. So, when it's first run it works, but when I try to run it again there's not enough space to complete the copying of the values which results in nothing being copied over.
Any suggestions on a better way to get what I'm trying to do done?
Thanks,
Dan
I'm trying to copy a range of values from one sheet to another, and then filter out any NA() errors. So far, I have the following bit of code:
Code:
Sub CopyExtQuery()' Copies the query for the extended report from the Calculations sheet. Filters out NA() errors after copying.
Sheets("Calculations").Range("C56:C2600").Value = Sheets("Extended Report").Range("A9:A2553").Value
Sheets("Calculations").Range("G56:G2600").Value = Sheets("Extended Report").Range("E9:E2553").Value
Application.CutCopyMode = False
Range("A8:D8").Select
ActiveSheet.Range("$A$8:$H$2553").AutoFilter Field:=1, Criteria1:="#N/A"
Rows("9:9").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
Range("A8:H8").Select
ActiveSheet.ShowAllData
Selection.AutoFilter
End Sub
This works, sort of. The issue is it's a one and done sort of deal. The range being copied is the result of some calculations on a changing query of a database which determine whether or not I want the values to be copied (returning an NA() code if I want them excluded). The way I'm filtering the NA() codes is by filtering column A to just the NA() values and deleting those rows. The deleting of the rows also deletes the merging of the cells that I have, with A:D being merged and E:H being merged from row 9 down to row 2553. The same number of cells are merged in the Calculations sheet, and for the same number of rows. So, when it's first run it works, but when I try to run it again there's not enough space to complete the copying of the values which results in nothing being copied over.
Any suggestions on a better way to get what I'm trying to do done?
Thanks,
Dan