PDA

View Full Version : How do you write to worksheet in Excel 2007



mattrix
09-24-2019, 11:29 PM
My problem is I have a long column of times and a sparse column of values at those times. I want to fill another column with values interpolated between those in the sparse array.

This was doable in previous versions but appears to have been blocked in Excel 2007.

A simple example is,


Function abb()
ActiveSheet.Cells(3,1).value = 122333
abb = 'any thing'
End Function

In cell A1, I set =abb() and hit enter. I get #VALUE in A1 but nothing happen at A3.

A second question, for my initial problem, I want to create a range for the results that is the column of ActiveCell, ie if the function is in E1, the created range is E:E. How do I do this?

Thanks for your help.

Logit
09-25-2019, 04:53 AM
.


Option Explicit


Sub writetosheet()
ActiveSheet.Cells(3, 1).Value = 122333
End Sub

mattrix
09-25-2019, 08:56 AM
I tried calling your sub from my function, but same result.
Do I have to call the sub directly? How do I do that from a worksheet?
If I put it into a macro, how do I pass in the parameters?

JKwan
09-25-2019, 10:13 AM
try this

Option Explicit



Sub writetosheet(MyValue As String)
ActiveSheet.Cells(3, 1).Value = MyValue
End Sub
Sub test()
writetosheet "abc"
End Sub

Paul_Hossler
09-26-2019, 03:42 PM
My problem is I have a long column of times and a sparse column of values at those times. I want to fill another column with values interpolated between those in the sparse array.

This was doable in previous versions but appears to have been blocked in Excel 2007.

A simple example is,

In cell A1, I set =abb() and hit enter. I get #VALUE in A1 but nothing happen at A3.

A second question, for my initial problem, I want to create a range for the results that is the column of ActiveCell, ie if the function is in E1, the created range is E:E. How do I do this?

Thanks for your help.

A WS function can't do things to other cells, like entering a value 3 rows down, adding color, change font, etc.

So '=abb()' in A1 will return "any thing" to A1


Function abb()
abb = "any thing"
End Function

I don't thing this was ever do-able

You could write a Sub() to do it, but your requirements are not clear to me