我设置了所有变量,但我仍然不断收到错误"需要对象"在
For Each cll In OHLC
这是我的代码:
Sub hellohello()
Dim i As Integer
Dim OHLC, cll As Range
Dim stoplossb, entrypriceb As Variant
stoplossb = 1
entrypriceb = 1
i = 1
For i = 63 To 166
If Range("M" & i).Value = "buy" Then
stoplossb = Range("X" & i)
entrypriceb = Range("w" & i)
Set OHLC = Range("B" & i & ":" & "E10000")
' Set twndlow = Range("K" & i & ":" & "K10000")
End If
For Each cll In OHLC
If cll.Value < stoplossb Then
Range("Y" & cll.Row) = cll.Value
Exit For
End If
Next cll
Next i
End Sub
我的错误是什么?
答案 0 :(得分:0)
在结束if之前,在else语句中将OHLC设置为空范围。
或者将if放在if块
中Sub hellohello()
Dim i As Integer
Dim OHLC, cll As Range
Dim stoplossb, entrypriceb As Variant
stoplossb = 1
entrypriceb = 1
i = 1
For i = 63 To 166
If Range("M" & i).Value = "buy" Then
stoplossb = Range("X" & i)
entrypriceb = Range("w" & i)
Set OHLC = Range("B" & i & ":" & "E10000")
' Set twndlow = Range("K" & i & ":" & "K10000")
For Each cll In OHLC
If cll.Value < stoplossb Then
Range("Y" & cll.Row) = cll.Value
Exit For
End If
Next cll
End If
Next i
End Sub
答案 1 :(得分:0)
您收到错误的原因是因为您的IF语句不正确,因此您永远不会到达将OHLC设置为范围的行。由于范围从未设定,因此范围等于零。
答案 2 :(得分:0)
答案 3 :(得分:0)
hlineMinus = 0;
//for (var i = 0; i < 21; i++) {
var doc = app.activeDocument;
imageWidth = activeDocument.width.as('px');
imageHeight = activeDocument.height.as('px');
imageWidth - 24;
imageHeight - 24;
hline = i+1 * 24;
hlineMinus = 0;
if(hline = 21*24)
hlineMinus += hline;
hline=hlineMinus;
var bounds = [24*(i), 0, 24*(i+1), 24*(i+1)];
doc.crop(bounds);
//do the math to figure out how big you want it after resize
//doc.resizeImage(newWidth, newHeight);
//note this is saving over the original!!!!
var opts, file;
opts = new ExportOptionsSaveForWeb();
opts.format = SaveDocumentType.PNG;
opts.PNG8 = false;
opts.quality = 100;
var d = i;
pngFile = new File(doc.path + d + doc.name );
app.activeDocument.exportDocument(pngFile, ExportType.SAVEFORWEB, opts);
//app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
//stepHistoryBack();
//}
function stepHistoryBack(){
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "HstS" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Prvs" ));
desc.putReference(charIDToTypeID( "null" ), ref);
executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
};