Consulting

Results 1 to 5 of 5

Thread: How do you write to worksheet in Excel 2007

  1. #1

    How do you write to worksheet in Excel 2007

    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.

  2. #2
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    613
    Location
    .
    Option Explicit
    
    
    Sub writetosheet()
        ActiveSheet.Cells(3, 1).Value = 122333
    End Sub

  3. #3
    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?

  4. #4
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    try this
    Option Explicit
    
    
    
    Sub writetosheet(MyValue As String)
        ActiveSheet.Cells(3, 1).Value = MyValue
    End Sub
    Sub test()
        writetosheet "abc"
    End Sub

  5. #5
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    Quote Originally Posted by mattrix View Post
    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
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •