Cell formula promlem - Excel macro

AI Thread Summary
The discussion centers around troubleshooting a macro code issue in Excel where a "##Name" error occurs due to improperly defined formulae. The user is attempting to utilize a dynamic range called "Patientrange" in various statistical functions but encounters errors. Suggestions from other participants include checking the initialization of the variable "Infocol" and dropping the ".Address" from range specifications. Ultimately, the user discovers that the correct way to reference the dynamic range in the formula is to concatenate it into the string, changing the formula from ActiveCell.Formula = "=MEDIAN(Patientrange)" to ActiveCell.Formula = "=MEDIAN(" & Patientrange & ")". This adjustment resolves the issue with the formula not working as intended.
big man
Messages
241
Reaction score
0
Hi

I have been having a problem with a section of my code in the macro that I've created. The problem is that the formulae that I want to use aren't working and soe I get a "##Name" error in the cells where the formula is supposed to have worked.

Patientrange = Range(PatAgeLet & "2" & ":" & PatAgeLet & Locator).Address
For Count = 2 To 6
FormulaRange1 = Range(Infocol & Count).Offset(0, 1).Address
FormulaRange2 = Range(Infocol & Count).Offset(0, 2).Address
NewRange = Range(FormulaRange1 & ":" & FormulaRange2).Select
With Selection
.NumberFormat = "0"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
If Count = 2 Then
ActiveCell.Formula = "=MIN(PatientRange)"
ElseIf Count = 3 Then
ActiveCell.Formula = "=MAX(Patientrange)"
ElseIf Count = 4 Then
ActiveCell.Formula = "=MEDIAN(Patientrange)"
ElseIf Count = 5 Then
ActiveCell.Value = Rangarrsize
ElseIf Count = 6 Then
ActiveCell.Formula = "=COUNTIF(Patientrange, ""<=40"")"
End If
Next Count

As you can see by this code Patientrange is a dynamic range and so this is the range that I want to use in my formulae. However, it just isn't working at all.

Any suggestions??
 
Technology news on Phys.org
Try dropping the .address from your range specifications.

I do not see where you have initialized Infocol.

Do not give up keep reading the help on how to specify a range.
 
Thanks for the reply Integral. Sorry about that but I was only providing a segment of the code so that's why you saw that infocol wasn't initialised.

I'm not sure if you're interested at all, but I found out what the problem was. When you specify the formula with the dynamic range you must put the dynamic range in quotes so instead of having ActiveCell.Formula = "=MEDIAN(Patientrange)" you must have ActiveCell.Formula = "=MEDIAN(" & Patientrange & ")".
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Back
Top