Results 1 to 4 of 4

Thread: Reference textbox data from excel function

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    29

    Reference textbox data from excel function

    I have created textbox1 on an excel spreadsheet and placed a number in it. I have written a function to get that number into an excel cell:

    Public Function GetValue(Obj as Object)
    Dim x as String

    x = Obj.Value
    GetValue = x
    End Function


    then in excel cell I call function:

    =GetValue(TextBox1)

    I can't get this work and feel I must be missing something pretty basic. It would be very valuable to be able to place data in textboxes, comboxes, etc. and then reference that data in excel functions for use use in excel formulas.
    Regards, Dennis

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Reference textbox data from excel function

    Are you doing this only in Excels VBA or automating Excel from VB 6?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2005
    Posts
    29

    Re: Reference textbox data from excel function

    I am doing this in excel vba - 1) Open excel and create textbox 2) Switch (Alt+F11) to VBA and write function 3)Switch back (Alt+F11) to excel sheet and try to use function. I can access contains via a Sub procedure and write to excel cell. The funtion would be much more powerful. Regards, dencur

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Reference textbox data from excel function

    Moved to Office Development.

Posting Permissions

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



Click Here to Expand Forum to Full Width