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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Simple VB question

  • 08-06-2005 3:27pm
    #1
    Registered Users, Registered Users 2 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,919 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, Registered Users 2 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,259 ✭✭✭RicardoSmith


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


Advertisement