Hi - I have written a simple macro that takes a column of data & creates 3 temperature columns of data tempK, tempC, tempF. These are actually Names that I create.
When I run the macro on a new file, it doesn't seem to re-define tempK (for instance) as a cell range, and instead tries to use the original tempK cell range defined when I had created the macro...
How can I modify my macro so that the tempK Name is re-defined anew every time the macro is invoked ?
Sub temp_uniformity()
'
'
Range("A25:I25").Select
Selection.Cut Destination:=Range("B25:J25")
Range("L25").Select
ActiveCell.FormulaR1C1 = "tempK"
Range("M25").Select
ActiveCell.FormulaR1C1 = "tempC"
Range("N25").Select
ActiveCell.FormulaR1C1 = "tempF"
Range("L26").Select
ActiveCell.FormulaR1C1 = "=(RC[-8]/0.0000000000366)^0.25"
Range("L26").Select
Selection.AutoFill Destination:=Range("L26:L5025"), Type:=xlFillDefault
Range("L26:L5025").Select
ActiveWorkbook.Names.Add Name:="tempK", RefersToR1C1:= _
"='cylinderPOB-50facets-10000raysA'!R26C12:R5025C12"
Range("M26").Select
ActiveCell.FormulaR1C1 = "=RC[-1]-273.15"
Range("M26").Select
Selection.AutoFill Destination:=Range("M26:M5025"), Type:=xlFillDefault
Range("M26:M5025").Select
ActiveWorkbook.Names.Add Name:="tempC", RefersToR1C1:= _
"='cylinderPOB-50facets-10000raysA'!R26C13:R5025C13"
Range("N26").Select
ActiveCell.FormulaR1C1 = "=(RC[-2]-273.15)*1.8+32"
Range("N26").Select
Selection.AutoFill Destination:=Range("N26:N5025"), Type:=xlFillDefault
Range("N26:N5025").Select
ActiveWorkbook.Names.Add Name:="tempF", RefersToR1C1:= _
"='cylinderPOB-50facets-10000raysA'!R26C14:R5025C14"
Range("L22").Select
Selection.FormulaArray = "=STDEV(IF(tempK=0,"""",tempK))"
Range("M22").Select
Selection.FormulaArray = "=STDEV(IF(tempC=-273.15,"""",tempC))"
Range("N22").Select
Selection.FormulaArray = "=STDEV(IF(tempF=-459.67,"""",tempF))"
Range("M18").Select
End Sub
Thanks !
ak
Bookmarks