①文末のダブルクォーテーションを出力する方法を教えて下さい。 print(" Cells(2, myRelation) = ""<=""") print(" Cells(2, myRelation) = """""<=""""") print(" Cells(2, myRelation) = """""<=""""""""") 出力結果 Cells(2, myRelation) = <= Cells(2, myRelation) = "<= Cells(2, myRelation) = "<= ②一方しか使えない?時はどうしたらいいですか? ③一括で変換(vba→python用)できるエディタありますか? 1行づつ、修正しました。 よろしくお願いします。 ## (参考) 以下は、シングルクォーテーションの時は、ダブルクォーテーション ダブルクォーテーションの時は、シングルクォーテーション で対応しました。 (参考)Pythonのシングルクォーテーションとダブルクォーテーションの使い分けってどうするの問題 https://qiita.com/thimi0412/items/95bd255c84d38ec9a400 https://ja.stackoverflow.com/questions/75328/excel%e3%81%ae%e3%82%bd%e3%83%ab%e3%83%90%e3%83%bc%e3%82%92vba%e3%81%a7%e8%87%aa%e5%8b%95%e5%8c%96%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95-%e6%9c%80%e5%b0%8f%e5%80%a4%e3%82%92%e3%82%84%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f print("'最大値最小値2*x+y") print("'制約条件4*x+y <= 9, x+2*y >= 4,2*x-3*y >= -6") print("'(x,y)=(3/2,3) max=6") print("'(x,y)=(0 ,2) min=2") print('Sub maxmin_MySolver()') print(' Const myRow As Long = 3') print(' Const startRow As Long = 2') print(' Dim i As Long') print('') print(' myRelation = 3') print(' myFormula = 4') print(' myRefer = 5') print(' mymaxRow = 5') print(' myminRow = 6') print(' ') print(' Cells(1, 1) = 2') print(' Cells(1, 2) = 1') print('') print(' Cells(2, 1) = 4') print(' Cells(2, 2) = 1') print(' Cells(2, myRelation) = "<="') print(' Cells(2, myFormula) = 9') print(' Cells(2, myRefer) = "=RC1*R5C1+RC2*R5C2"') print(' Cells(2, myRefer + 1) = "=RC1*R6C1+RC2*R6C2"') print('') print(' Cells(3, 1) = 1') print(' Cells(3, 2) = 2') print(' Cells(3, myRelation) = ">="') print(' Cells(3, myFormula) = 4') print(' Cells(3, myRefer) = "=RC1*R5C1+RC2*R5C2"') print(' Cells(3, myRefer + 1) = "=RC1*R6C1+RC2*R6C2"') print('') print(' Cells(4, 1) = 2') print(' Cells(4, 2) = -3') print(' Cells(4, myRelation) = ">="') print(' Cells(4, myFormula) = -6') print(' Cells(4, myRefer) = "=RC1*R5C1+RC2*R5C2"') print(' Cells(4, myRefer + 1) = "=RC1*R6C1+RC2*R6C2"') print('') print(' myMaximize = 1') print(' Cells(5, myRelation) = "max"') print(' Cells(5, myFormula) = "=R1C1*RC1+R1C2*RC2"') print('') print(' SolverReset') print(' SolverOk setCell:=Cells(mymaxRow, myFormula), _') print(' MaxMinVal:=myMaximize, _') print(' ByChange:=Range(Cells(mymaxRow, 1), Cells(mymaxRow, 2)), _') print(' EngineDesc:="Simplex LP"') print('') print(' For i = startRow To startRow + myRow - 1') print(' SolverAdd CellRef:=Cells(i, myRefer), _') print(' Relation:=myFutogo(Cells(i, myRelation)), _') print(' FormulaText:=Cells(i, myFormula)') print(' Next i') print(' SolverSolve UserFinish:=True') print('') print(' myMinimize = 2') print(' Cells(myminRow, myRelation) = "min"') print(' Cells(myminRow, myFormula) = "=R1C1*RC1+R1C2*RC2"') print('') print(' SolverReset') print(' SolverOk setCell:=Cells(myminRow, myFormula), _') print(' MaxMinVal:=myMinimize, _') print(' ByChange:=Range(Cells(myminRow, 1), Cells(myminRow, 2)), _') print(' EngineDesc:="Simplex LP"') print('') print(' For i = startRow To startRow + myRow - 1') print(' SolverAdd CellRef:=Cells(i, myRefer + 1), _') print(' Relation:=myFutogo(Cells(i, myRelation)), _') print(' FormulaText:=Cells(i, myFormula)') print(' Next i') print(' SolverSolve UserFinish:=True') print('') print('End Sub') print('Function myFutogo(Moji As String) As Long') print(' If Moji = "<=" Then') print(' myFutogo = 1') print(' ElseIf Moji = ">=" Then') print(' myFutogo = 3') print(' End If') print('End Function') print("'x:cells(5,1)=1.5") print("'y:cells(5,2)=3") print("'max:cells(5,4)=6") print("'x:cells(6,1)=0") print("'y:cells(6,2)=2") print("'min:cells(6,4)=2")