+ Reply to Thread
Results 1 to 4 of 4

Write Text to Cell - Failure

Hybrid View

  1. #1
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    It seems that the issue is that you are enterring the text into the wrong cell. In VBA, the line ActiveSheet.Cells(1,1) actually refers to cell row 1, column 1, or cell A1 as its commonly called.

    You code should look as follows:

    Public Sub FundTransfer()
        Dim textout As String
        
       
        textout = "test"
        
        Range("H388") = textout
    End Sub
    Try that out and report back.

  2. #2
    Registered User
    Join Date
    10-05-2008
    Location
    Santa Fe
    Posts
    2

    Making progress - thanks

    BasBas,

    Yes, I have been able to get your example to work, and I thank you very much. I was not able to get on the forum for a good part of the day - website error messages being generated.

    If you are still interested, here is the next stage of the problem.
    I was trying to get a date entry in a cell to transfer over to a different cell but can only get it in a numeric form. This code works through the stage of the MsgBox and the date does come out in a proper string format. But when I try to copy the very same string into a cell, I can only get a numeric form. So the last line of code is apparently failing or not doing what I expect it to.

    More curiosity now than anything, as I am actually on to the next stage of my project, and am VERY SLOWLY making progress. I try a lot of examples straight from my books and they just don't seem to work smoothly and the debugging feedback is very minimal to non existent. I eventually find something that starts to work after putting about 3 different sources and examples together.


    I will just keep plugging along until the next roadblock, but I am starting to make progress. General problem is to enter a date in an input box, match that date with a row in the spreadsheet that contains that date in one cell, and then to extract numerous other data entries in that same row and then transfer those data entries to another worksheet where they are processed further.

    Thanks much for all help, from Clifford

    No essential need to reply to this post...

    Public Sub FundTransfer()
        Dim fundamentaldate As String
        Dim dt As Date
        
        Range("H388").Select
        InputBox ("Enter Date of Transfer - MO/DY/XXXX")
        dt = Range("A409")
        fundamentaldate = FormatDateTime(dt, vbShortDate)
        MsgBox (fundamentaldate)
        Range("H388") = fundamentaldate
        
        
          
        
        
    End Sub

  3. #3
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394
    Not exactly sure what you are trying to do, but here are some comments from me that hopefully will help
    • You don't really need to use Public before Sub.
    • it would seem that your line Range("H388").Select doesn't actually do anything, so you can skip it. You don't need to select a cell before you can update its contents
    • Your Input box doesn't store the input data anywhere, you normally would put the results to a variable
    • So the following does essentially the same thing, but with less code, and actually capturing the input box (not sure what you want to do with it).

    Sub FundTransfer()
        Dim fundamentaldate As String
        Dim dt As Date
        Dim NewDate as Date
    
        NewDate=InputBox ("Enter Date of Transfer - MO/DY/XXXX")
        dt = Range("A409")
        fundamentaldate = FormatDateTime(dt, vbShortDate)
        MsgBox (fundamentaldate)
        Range("H388") = fundamentaldate
        
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Append Cell Values To Text Files
    By Stefan.S. in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-17-2008, 11:09 AM
  2. Trying to append text into a cell with different colours
    By Earl in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2008, 05:23 PM
  3. Treating a cell as text
    By spr1nt in forum Excel General
    Replies: 1
    Last Post: 07-15-2008, 04:42 AM
  4. Scrolling text in a Cell
    By Robert Bob in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-26-2007, 06:47 PM
  5. Replies: 7
    Last Post: 12-22-2006, 06:34 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1