0
ActiveWorkbook.Names.Add Name:="RecordCount", _
                 RefersToR1C1:="=qryTC2015ContainerUtilizationSh!R1C100"

    Range("CV1").Select
    ActiveCell.FormulaR1C1 = "=COUNTA(C[-99])"

    RecordCount = Range("RecordCount")
    
    
    
    
    Range("A2:N" & RecordCount).Select
    
    'Range(Selection, Selection.End(xlDown)).Select
    
    Selection.Copy
    
    Windows("TC Containers Shipped Report Template.xlsm").Activate
          
    Sheets("Container Utilization").Select

    Range("A2").Select

    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=False

what would the problem be and how can it be fixed?

Tim Williams
  • 154,628
  • 8
  • 97
  • 125

1 Answers1

0

It looks like you are expecting a number out of that line and all you are doing is referring to a range. If you wanted the number of records you would need it to be `Range("RecordCount").Count", which will return the number of cells in the range, not the number of cells with values. If you want the number of records in column N, it is better to find the last row as previously suggested.

Dim LastRow as Long
LastRow = Cells(Rows.Count, "N").End(xlUp).Row

Range("A2:N" & LastRow).Copy

Workbooks("TC Containers Shipped Report Template").Sheets("Container Utilization").Range("A2").PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    
Darrell H
  • 1,876
  • 1
  • 9
  • 14