当自动过滤并且没有数据或只有一种类型的数据时,我在线上出现错误
Set rang = rang.Resize(rang.Rows.Count - 1)
在下面的代码中我只有来自criteria2的数据
Dim rang As Range
Set sh = Worksheets("ExampleSheet")
sh.Select
Range("A1").Select
Selection.AutoFilter
sh.UsedRange.AutoFilter Field:=10, Criteria1:= _
"=*Criteria1*", VisibleDropDown:=False
Set rang = sh.UsedRange.Offset(1, 0)
Set rang = rang.Resize(rang.Rows.Count - 1)
On Error Resume Next
Set rang = rang.SpecialCells(xlCellTypeVisible)
If Err.Number = 0 Then
rang.Select
rang.Copy
Sheets("Criteria2").Select
Range("A1").Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
sh.Select
Selection.Delete Shift:=xlUp
End If
On Error GoTo 0
sh.Cells.AutoFilter
Application.CutCopyMode = False
sh.Select
Range("A1").Select
Selection.AutoFilter
sh.UsedRange.AutoFilter Field:=10, Criteria1:= _
"=*Criteria2*", VisibleDropDown:=False
Set rang = sh.UsedRange.Offset(1, 0)
Set rang = rang.Resize(rang.Rows.Count - 1)
On Error Resume Next
Set rang = rang.SpecialCells(xlCellTypeVisible)
If Err.Number = 0 Then
rang.Select
rang.Copy
Sheets("Criteria2").Select
Range("A1").Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
sh.Select
Selection.Delete Shift:=xlUp
End If
On Error GoTo 0
sh.Cells.AutoFilter
Application.CutCopyMode = False
答案 0 :(得分:1)
library(seewave)
library(tuneR)
nsamps <- 600 # number of samples to create
sf <- 10 # sampling frequency of the data in Hz
fout <- 22000 # Sample frequency of output sound (Hz)
dout <- 10 # length of output sound file (seconds)
# some dummy amplitude data, 3 columns
df <- data.frame(f1 = sin((1:nsamps)/180*pi)+1, f2 = sin((1:nsamps)/180*pi + pi)+1, f3 = sin((1:nsamps)/90*pi)+1)
mat <- as.matrix(df)
freqs <- seq(100, 1000, length.out = ncol(mat)) # Carrier frequencies for each data column (Hz)
syn <- 0 # this is the synthesised wave
atemp <- seq(from=1, to=nrow(mat), length.out = fout*dout) # new times
for(ii in 1:ncol(mat)){ # for each data column
scale_data <- (mat[,ii] - min(mat[,ii]))/diff(range(mat[,ii])) # scale each column between 0 and 1, comment out for absolute amplitudes across all columns
amp <- approx(x = 1:nrow(mat), y = scale_data, xout = atemp)$y # sample the amplitude data onto the new times
syn <- syn + synth(f = fout, d = dout, cf = freqs[ii], output = 'wave', a = amp) # build up the total synth wave
}
wave <- Wave(left = syn, samp.rate=fout, bit=16) # create a wave class
listen(wave) # listen to the sound