Dec 09 2020 04:55 AM - edited Dec 09 2020 05:01 AM
Hi everyone,
I have a list of ranges in excel, and I'm trying to write VBA code that gets each range in turn and inputs it into solver constraints, so the solver works on a different range each iteration. This is where I'm up to so far:
Sub solvermacro3()
Dim i As Integer
Dim Z As Integer
Dim Y As String
For i = 0 To 2
Z = 38 + i
Y = CStr(Z)
' solvermacro3 Macro
SolverReset
SolverAdd CellRef:=Sheets("data").Range("INDIRECT(GG&Y)"), Relation:=5, FormulaText:="binary"
Obviously theres a bunch more code after but this is the relevant bit. When it tries to run, I get an error 1004 object defined error, but it runs fine if I just use "GG38" as the argument for the indirect, so I know the problem is related to the "&Y" bit. I'm very new to VBA so please go easy on me if I'm doing anything really stupid. Thanks in advance for your hel