Consulting

Results 1 to 7 of 7

Thread: Setting Linked cell to another work sheet

  1. #1
    VBAX Newbie
    Joined
    Feb 2020
    Posts
    4
    Location

    Setting Linked cell to another work sheet

    Hi All

    Having a bit of trouble setting the linked cell of an ActiveX Textbox to a cell in another worksheet

    If i have the data in the same active sheet as the "Gui" everything works fine but I want the Linked cell to be located in another worksheet ("Paymech")

    I tried using the following code:

    Worksheets("Gui").OLEObjects("Tinbox").LinkedCell = Worksheets("Paymech").Range("J" & tinvalue).Address

    This didnt work is stays linked to the active sheet "Gui"

    Can anyone point me in the right direction?

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    Add:
    (External:=True)
    to the end of that line.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Newbie
    Joined
    Feb 2020
    Posts
    4
    Location
    thanks P45cal that did it my hero

  4. #4
    VBAX Newbie
    Joined
    Feb 2020
    Posts
    4
    Location
    Ok slight problem, the Textbox is importing a time formatted cell and displaying it a number, 07:27:49 is being displayed as 0.26875.

    Original line:
    Worksheets("Gui").OLEObjects("Timebox").LinkedCell = Worksheets("Paymech").Range("C" & tinvalue).Address(External:=True)

    I tried the following to format the box with the follwing but only got errors
    Format(Worksheets("Gui").OLEObjects("Timebox").LinkedCell, "HH:MM:SS") = Worksheets("Paymech").Range("C" & tinvalue).Address(External:=True)

    Apologies if im asking rather 'noddy' questions

  5. #5
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    How you approach this depends on whether the user will be updating the textbox in the text box itself, and the linked cell then takes on that value, or the other way round, the cell will be updated leading to an update in the textbox.
    Textboxes are usually there to accept input from a user (otherwise you'd use a label).
    So a bit more context needed to give you a good answer.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  6. #6
    VBAX Newbie
    Joined
    Feb 2020
    Posts
    4
    Location
    So the project im working on is for importing and displaying an automatically generated spreadsheet full of incidents for discussion at a meeting

    9/10 times out the information on the spreadsheet is correct however occasionally there is limited information given when the incident is reported, usually its exact time of incident. So what tends to happen is people fill the time field with a rough estimate, for example the it would appear on the generated spreadsheet as lets say 16:00:00, later we may get an exact time of incident 15:53:47. and need to update it.

    I wanted to use activeX text boxes as a bit of GUI that would display the information but also allow me to edit it if anything was found to be incorrect

    The automatically generated spreadsheets already formats the info as HH:MM:SS

  7. #7
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    So you start with this automatically generated spreadsheet full of incidents, I'm guessing, one row per incident, and you display individual incidents (a single row's data) in a separate GUI, allow that GUI to be amended and then update that same row in the automatically generated spreadsheet full of incidents?
    Currently you're filling the various text boxes using the linked cell of each text box, so that it will carry changes back to the automatically generated spreadsheet full of incidents?
    Since you're using vba to do this I suggest there are more robust ways.
    I'll help as much as I can but I'm not going to try and reproduce your scenario, guessing wrongly while I do so, to experiment with, so could you attach a (de-sensitised) version of your workbook here, or if that's not possible and you're happy for only me to see stuff that's not for the public domain, ask me for an email address and I'll send you it via a Private Message here and you'll be able to send me something that way.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

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