# Posts by Philosophaie

How do you make an Array to send thru to a function?

How do I program more than one conditional formula?

In Cells:
B11=35
B12=25
B13=45
=IF(B11>=B12 & B12<=B13,"T","F")
F
it should be "T"

In Cells:
B16=1
B17=2
=IF((B16<>B17 AND B16<B17),"TRUE","FALSE")
#NAME?

In ASP.net you can combine a group a variables as a Class and send them to a function.

How do you do this in a Subroutine transferring it to a Function extracting the data to use in the function?

How do you take the factorial of a number in VBA: k!.

I keep getting a "type mismatch" error.
I have tried dim to double on all quantities and add "As Double" to the end of

Code
``"Function apparent(Byval v As Double, Byval b As Double, Byval T As Double) As Double"``

That gives the same "type mismatch" error.

I am trying to automate the graphing process.

I am having problems with .Range(.cells(4,n),.cells(14,n))

Code
``````n = 5
For m = 1 To 5
Sheets("Sheet1").ChartObjects("Chart 1").Chart.SeriesCollection(m).XValues = Sheets("Sheet2").Range(Sheets("Sheet2").Cells(4, n), Sheets("Sheet2").Cells(14, n))
n = n + 1
Sheets("Sheet1").ChartObjects("Chart 1").Chart.SeriesCollection(m).Values = Sheets("Sheet2").Range(Sheets("Sheet2").Cells(4, n), Sheets("Sheet2").Cells(14, n))
Sheets("Sheet1").ChartObjects("Chart 1").Chart.SeriesCollection(m).Name = "Names" & m
n = n + 1
Next m``````

Here is an excerpt of the code:
forum.ozgrid.com/index.php?attachment/67131/

## Files

Re: Method 'Range' of object'_Worksheet' failed

forum.ozgrid.com/index.php?attachment/66985/

I know there is a simpler way to just do a simple range.

I eventually want to loop the plot to include more columns.

Here is an example of how a Range in another sheet is not working. See above.

## Files

Re: Method 'Range' of object'_Worksheet' failed

Here is the whole thing. the chart objects: "XValue" and "Value" are where the errors are.

Re: Method 'Range' of object'_Worksheet' failed

Still get an error. Sheets "Sheet1" and "Sheet2" exist.

Code
``Set rng1 = Sheets("Sheet1").Range(Sheets("Sheet2").Cells(4, 1), Sheets("Sheet2).Cells(28, 1))``

Error:
"Application-defined or object-defined error"

This code is being run on "Sheet1".

Code
``Set rng1 = Range(Sheets("Sheet2").Cells(4, 1), Sheets("Sheet2").Cells(28, 1))``

Error:

Quote

"Method 'Range' of object'_Worksheet' failed"

I have a function that returns an alphabetical column label for each numerical column label, alphacol().

I am getting a error on the "rng1.Value" line:

Quote

"Invalid Parameter"

Code
``````Dim rng1 As Range
string1 = alphacol(15) & "4:" & alphacol(15) & "13"
Set rng1 = Sheets("PlotData").Range(string1)
Sheets("Graph").ChartObjects("Chart 1").Chart.SeriesCollection(1).XValues = rng1.Value``````

If I replace the line:

Code
``Sheets("Graph").ChartObjects("Chart 1").Chart.SeriesCollection(1).XValues = rng1.Value``

I also get the error:

Quote

"Invalid Parameter"

I have data in each cell of "C5:E7"
Error code:

Quote

"Application-defined or object-defined error"

Code
``````Private Sub CommandButton1_Click()
Dim rng1 As Range, rng2 As Range
string1 = "C5:E7"
string2 = "C12:E14"
Set rng1 = Range(string1)
Set rng2 = Range(string2)
Sheets(1).Range(rng2) = Sheets(1).Range(rng1)
End Sub``````

I have an active working Chart1 but I want to clear it every time I click the button to execute the Chart.

How do I do that?

Code
``Sheets("Graph").ChartObjects("Chart 1").Chart.???``

I have made a function that converts column numbers to column letters, alphacol.

I am having trouble reading the Range, rng1 after it has been set.

There is an error: "Object does not support this property or method"
on line: "Sheets("Graph").ChartObjects("Chart 1").Chart.SeriesCollection(k).XValues = Sheets("PlotData").rng1"

If I change rng1 to Range(rng1) I get this error: "Application-defined or object-defined error"
on this line: "Sheets("Graph").ChartObjects("Chart 1").Chart.SeriesCollection(k).XValues = Sheets("PlotData").Range(rng1)"

How do I get the Range to work with the function?

Re: Missing quotation marks around the Range

Code
``Sheets("Graph").ChartObjects("Chart 1").Chart.SeriesCollection(k).XValues = Sheets("PlotData").Range(Hex(nn) & k +3 & ":" & Hex(nn) & Max)``

is highlighted. How do you put in quotation marks so it looks like ...Range("A3:A25")? You can not put in quotes before the Hex(nn) and after Max without messing up the string. I just want to know the other way to write a single quote.

I am trying to automate the plotting process.

Simply I think I am missing the quotation marks around the Range but I do not know how put them in with an "&" sign.

The error code is: "Parameter not Valid"

If it is not the quotation marks maybe it is something ele I am missing.

Here is my code:

I think the reason this will not work is the variables for the Do Loop are changing inside the Loop itself and Excel does not like that.
Is there any other Loops that may work in this case?

Code
``````E1 = Pi / 4 'Initialize
diff = 1 'Initialize
Do While Math.Abs(diff) > 0.00001
diff = (E1 - e(k) * Math.Sin(E1) - MA(k) * Pi / 180) / (1 + Math.Cos(E1))
E1 = E1 + diff
Loop``````

Tried

Code
``````Do Until Math.Abs(diff) < 0.00001
diff = (E1 - e(k) * Math.Sin(E1) - MA(k) * Pi / 180) / (1 + Math.Cos(E1))
E1 = E1 + diff
Loop``````

Code
``````Do
diff = (E1 - e(k) * Math.Sin(E1) - MA(k) * Pi / 180) / (1 + Math.Cos(E1))
E1 = E1 + diff
Loop While Math.Abs(diff) > 0.00001``````

A For or a ForEach will not work in this case.

Do Loop are changing inside the Loop itself

I think the reason this will not work is the variables for the Do Loop are changing inside the Loop itself and Excel does not like that.
Is there any other Loops that may work in this case?

Code
``````E1 = Pi / 4 'Initialize
diff = 1 'Initialize
Do While Math.Abs(diff) > 0.00001
diff = (E1 - e(k) * Math.Sin(E1) - MA(k) * Pi / 180) / (1 + Math.Cos(E1))
E1 = E1 + diff
Loop``````

Tried

Code
``````Do Until Math.Abs(diff) < 0.00001
diff = (E1 - e(k) * Math.Sin(E1) - MA(k) * Pi / 180) / (1 + Math.Cos(E1))
E1 = E1 + diff
Loop``````

Code
``````Do
diff = (E1 - e(k) * Math.Sin(E1) - MA(k) * Pi / 180) / (1 + Math.Cos(E1))
E1 = E1 + diff
Loop While Math.Abs(diff) > 0.00001``````

A For or a ForEach will not work in this case.

[INDENT]Getting an error on the line where you calculate "diff".
I am certain the equations are correct.

E1 is in Radians and MA(k) and EA(k) are in Degrees.
e(k) is no Units.

Error code:

Quote

Invalid procedure call or argument.

Code:

What am I doing wrong?[/INDENT]