Consulting

Results 1 to 4 of 4

Thread: I Want Get =EMBED("Forms.ListBox.1";"")'s Value to Cell...

  1. #1
    VBAX Tutor Erdin? E. Ka's Avatar
    Joined
    Sep 2006
    Location
    Bursa
    Posts
    264
    Location

    I Want Get =EMBED("Forms.ListBox.1";"")'s Value to Cell...

    Hi everyone,

    I have to ListBox Control on Sheet1. I tried get their value to a cell via formula but i couldn't solve it.

    [VBA]=EMBED("Forms.ListBox.1";"")[/VBA]

    Is there a way to get a page control's value via formula?

    If this is impossible;

    Can we coding for an UDF for all control types ?

    Example syntaxs:
    =GET_PAGE_CONTROL_VALUE("FullNameOfWorkBook","NameOfWorkSheet","NameOfContr olType")
    =GET_PAGE_CONTROL_VALUE("C:\Test.xls","Sheet1","ListBox1")
    =GET_PAGE_CONTROL_VALUE("C:\Test.xls","Sheet1","ComboBox1")
    =GET_PAGE_CONTROL_VALUE("C:\Test.xls","Sheet1","TextBox1")


    I attached my file.

    Thanks in advance.
    Erdin? E. Kara?am | Loves from Bursa city in Republic of T?rkiye

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Try
    [VBA]Sub Macro1()
    Range("D20") = ActiveSheet.ListBox1.Value
    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    This works pretty nicely:

    [VBA]Public Function Get_Page_Control_Value(ByVal strWB As String, _
    ByVal strWS As String, ByVal strControlName As String) As Variant
    ' Will return the selected or current value of an embedded object
    Application.Volatile True

    On Error GoTo ErrorHandler
    Get_Page_Control_Value = Workbooks(strWB).Sheets(strWS).OLEObjects(strControlName).Object.Value
    Exit Function

    ErrorHandler:
    Get_Page_Control_Value = CVErr(xlErrValue)
    End Function[/VBA]




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  4. #4
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Hmm...it's having trouble with the Checkbox. Add this to the ThisWorkbook class module:

    [VBA]Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    Calculate
    End Sub
    [/VBA]




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

Posting Permissions

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