Hi, it is strange that if I use equation in a single cell A1 and run the code below =3^10 to create all sets the code works perfectly fine.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
Equation 3^10<o></o>
<o></o>
But if I use the equation with 3^11 or 3^12 then the code gives an error of ‘1004’<o></o>
<o></o>
Equation 3^11<o></o>
<o></o>
<o></o>
Equation 3^12<o></o>
<o></o>
<o></o>
Here is the code: <o></o>
<o></o>
<o></o>
I’m using excel 2000. Is it the cause or I’m doing something wrong that’s why the code is producing an error? <o></o>
<o></o>
Please, can someone explain this?<o></o>
<o></o>
Thank in advance,<o></o>
Kishan<o></o>
<o></o>
Equation 3^10<o></o>
Rich (BB code):
<TABLE style="WIDTH: 605pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=806 x:str><COLGROUP><COL style="WIDTH: 605pt; mso-width-source: userset; mso-width-alt: 29476" width=806><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; WIDTH: 605pt; HEIGHT: 12.75pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" height=17 width=806>A1+A2+A3,B1+B2+B3,C1+C2+C3,D1+D2+D3,E1+E2+E3,F1+F2+F3,G1+G2+G3,H1+H2+H3,I1+I2+I3,J1+J2+J3</TD></TR></TBODY></TABLE>
But if I use the equation with 3^11 or 3^12 then the code gives an error of ‘1004’<o></o>
<o></o>
Equation 3^11<o></o>
Rich (BB code):
<TABLE style="WIDTH: 605pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=806 x:str><COLGROUP><COL style="WIDTH: 605pt; mso-width-source: userset; mso-width-alt: 29476" width=806><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; WIDTH: 605pt; HEIGHT: 12.75pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" height=17 width=806>A1+A2+A3,B1+B2+B3,C1+C2+C3,D1+D2+D3,E1+E2+E3,F1+F2+F3,G1+G2+G3,H1+H2+H3,I1+I2+I3,J1+J2+J3,K1+K2+K3</TD></TR></TBODY></TABLE>
<o></o>
Equation 3^12<o></o>
Rich (BB code):
<TABLE style="WIDTH: 605pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=806 x:str><COLGROUP><COL style="WIDTH: 605pt; mso-width-source: userset; mso-width-alt: 29476" width=806><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; WIDTH: 605pt; HEIGHT: 12.75pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" height=17 width=806>A1+A2+A3,B1+B2+B3,C1+C2+C3,D1+D2+D3,E1+E2+E3,F1+F2+F3,G1+G2+G3,H1+H2+H3,I1+I2+I3,J1+J2+J3,K1+K2+K3,L1+L2+L3</TD></TR></TBODY></TABLE>
<o></o>
Here is the code: <o></o>
Rich (BB code):
Option Explicit
Rich (BB code):
Rich (BB code):
<o:p></o:p>
Sub Create_abc_Sets() <o:p></o:p>
<o:p></o:p>
Dim Ans As Boolean, Col As Collection, i As Long<o:p></o:p>
Set Col = New Collection<o:p></o:p>
Ans = BuildLoops(Range("A1").Value, ",", Col)<o:p></o:p>
If Ans Then<o:p></o:p>
For i = 1 To Col.Count<o:p></o:p>
Cells(i + 2, 1).Value = Col(i) <o:p></o:p>
Next i<o:p></o:p>
Else<o:p></o:p>
MsgBox "Error !", vbCritical<o:p></o:p>
End If<o:p></o:p>
End Sub<o:p></o:p>
<o:p></o:p>
Function BuildLoops(ByVal St As String, Sep As String, ByRef Col As Collection) As Boolean<o:p></o:p>
Dim Ar As Variant, Ar2 As Variant, ArMain As Variant<o:p></o:p>
Dim i As Long, j As Long, Ctr As Long, TempSt As String<o:p></o:p>
St = Application.Substitute(St, " ", "")<o:p></o:p>
Ar = Split(St, Sep)<o:p></o:p>
If Not IsArray(Ar) Then Exit Function<o:p></o:p>
ReDim ArMain(1 To UBound(Ar) - LBound(Ar) + 1)<o:p></o:p>
For i = LBound(Ar) To UBound(Ar)<o:p></o:p>
Ar2 = Split(Ar(i), "+")<o:p></o:p>
Ctr = Ctr + 1<o:p></o:p>
ArMain(Ctr) = Ar2<o:p></o:p>
Next i<o:p></o:p>
For j = LBound(ArMain(1)) To UBound(ArMain(1))<o:p></o:p>
TempSt = ArMain(1)(j)<o:p></o:p>
BuildString 1, ArMain, Col, TempSt<o:p></o:p>
Next j<o:p></o:p>
BuildLoops = True<o:p></o:p>
End Function<o:p></o:p>
<o:p></o:p>
Private Function BuildString(ByRef i As Long, ByRef ArMain As Variant, ByRef Col As Collection, ByRef TempSt As String)<o:p></o:p>
Dim j As Long, St As String<o:p></o:p>
St = TempSt<o:p></o:p>
If i < UBound(ArMain) Then<o:p></o:p>
For j = LBound(ArMain(i + 1)) To UBound(ArMain(i + 1))<o:p></o:p>
TempSt = St & "," & ArMain(i + 1)(j)<o:p></o:p>
BuildString i + 1, ArMain, Col, TempSt<o:p></o:p>
Next j<o:p></o:p>
Else<o:p></o:p>
Col.Add UCase(TempSt)<o:p></o:p>
End If<o:p></o:p>
End Function
<o></o>
I’m using excel 2000. Is it the cause or I’m doing something wrong that’s why the code is producing an error? <o></o>
<o></o>
Please, can someone explain this?<o></o>
<o></o>
Thank in advance,<o></o>
Kishan<o></o>