Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Simple VB question

Options
  • 08-06-2005 4:27pm
    #1
    Registered Users Posts: 3,548 ✭✭✭


    Im relatively new to VB and especially new to using VB in conjunction with Excel.

    Heres a real newbie question:

    Can someone explain to me, maybe even give me a little code snippet, to write a string value into a cell in an excel worksheet please?

    Took me two minutes to figure out how to read from Excel but for the life of me cant get it to write to a worksheet. Its become a blur of .Cells and .Range!!


Comments

  • Moderators, Arts Moderators Posts: 35,471 Mod ✭✭✭✭pickarooney


    If I understand you correctly, you have a string variable whose value you want to copy into a particular cell? The way I'd do it is create a DataObject
    Dim MyDataObj As New DataObject
    Dim MyString As String
    
    MyString = "some stuff"
    
    MyDataObj.SetText MyString
    MyDataObj.PutInClipboard
    
    Range("A1").Select
    
    Selection.Paste
    

    Any use to you?


  • Registered Users Posts: 3,548 ✭✭✭Draupnir


    in the end it wasnt quite so complex. it turned out i was just having a bit of a brain fart. thanks for the help man.


  • Closed Accounts Posts: 8,264 ✭✭✭RicardoSmith


    Record a macro and look at the code it produces. Very handy if you get a duh moment.


Advertisement