1

I created a custom calendar form to insert a date into whether a cell on a sheet or a textbox on a form. When calling the form, I store the name of the target object (cell or textbox) in a cell on a sheet (named, say, targetObject). Then, I want the calendar form to insert the selected date into that object. My problem is that I can't find a way to refer to the target object. The code would look something like:

(in the calling code:)

-if to insert date into a cell:
    [targetObject].Value="A1"
-if to insert date into a textbox:
    [targetObject].Value="MyForm.MyDate"

(then, in the Calendar Form):

Object("targetObject").Value = someDate

Everything I tried to refer to the object whose name is stored in [targetObject] failed. Can someone, please, have an idea?

1
  • Post a code where you call custom calendar form... Does 'targetObject' is named range? Commented Oct 13, 2015 at 16:42

1 Answer 1

1

If you have the name of the control, then in the form code,

me.controls(controlName).Value = someValue
Sign up to request clarification or add additional context in comments.

1 Comment

The thing is when I run the Calendar form I don't know beforehand if the object whose value I need to set (by passing the date selected in Calendar) is a control on another form or is a cell on a sheet. My question is just about that: how can I refer the object to update when I only know its name, be it a cell or a control.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.