我有一个数组Option Explicit
Dim rng As Range
Dim shiftRng As Range
Sub ClearRow_Click()
Dim currRow As Long
Dim rng As Range
Dim rngShift As Range
currRow = ActiveCell.Row
'This is the full range of data
If rng Is Nothing Then Set rng = Range("A5:J300")
'This gets the next n rows to the last row of your range
If rngShift Is Nothing Then Set rngShift = Range("A" & (ActiveCell.Row + 1) & ":J300")
If currRow >= 5 And currRow <= 300 Then
'# This copies ONLY column A and moves the values up one row
' This will leave intact all of the rest of the data in columns B:J, etc.
' This preserves formatting -- essentially it just moves the values
rngShift.Columns(1).Offset(-1).Value = rngShift.Columns(1).Value
'# Get rid of the value in the last row, since it's been shifted up
Range("A300").ClearContents
End If
End Sub
。
如何删除&#34; NaN&#34;从数组?
请给我正确的方向。
答案 0 :(得分:3)
此处不需要强调。
arr = arr.filter( (el) => !Number.isNaN( el ) );
答案 1 :(得分:2)
拒绝NaN:
的元素 _.reject(array, _.isNaN)
答案 2 :(得分:1)
您可以使用compact
var arr = [15,34,595,NaN];
arr = _.compact(arr);
注意:每个文档compact
也会删除Javascript认为的任何其他内容falsy
false,null,0,&#34;&#34;,undefined和NaN