PDA

View Full Version : Setting Linked cell to another work sheet



Revier
02-12-2020, 11:26 AM
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?

p45cal
02-12-2020, 12:31 PM
Add:
(External:=True)
to the end of that line.

Revier
02-13-2020, 12:12 AM
thanks P45cal that did it my hero

Revier
02-13-2020, 02:36 AM
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

p45cal
02-13-2020, 06:41 AM
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.

Revier
02-13-2020, 08:07 AM
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

p45cal
02-13-2020, 08:40 AM
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.