Hi all,
How do I change the following code to r1c1 where I can substitue variables for the row and column numbers?
TextBox1.ControlSource = “=Data!a4”
Thanks,
Mike
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Textbox control source in R1C1 (2000)
Mike
OK so you want to allow the use of a variable control source for a text box, OK you really don’t need R1C1 notation all you need to do is say something like:
TextBox1.ControlSource = “=Data!” & Cells(lRowDesignator, iColumnDesignator)
But if you want to use R1C1 noatation then your example would be:
R4C1
HTH
Wassim
Well, I still cannot get this to work…
Private Sub ListBox1_Click() Dim bernadette As Integer Entry.Label15.Caption = ListBox1.Value For Each cell In ThisWorkbook.Sheets("Data").Range("b3:af3") If Str(cell.Value) = ListBox1.Value Then bernadette = cell.Column Exit For End If Next TextBox1.ControlSource = "=Data!R6C" & bernadette End Sub
Any ideas?
I get the attached message. (By the way how do you put the image into the post?)
Edited by me to add this
Nevermind about the image, I see Woody put it there just by attaching it!
So you used
TextBox1.ControlSource = Sheets("Data").Cells(6,bernadette).Address
Is that correct? Now works for me, but I would have never thought to do it that way. That is totally bizzare! Glad you solved the problem: trying to figure out what was happening on my test sheet was really bugging me!
Nothing bizarre about it, it makes sense. If you set the ControlSource property manually, you type Sheet1!$A$1 or some-such into the field in the properties sheet.
In online help, it says: “If ControlSource contains a value other than an empty string, it identifies a linked cell or field.”
Sheets("Data").Cells(6,bernadette)
is a range, not a string. To get the string that identifies the linked cell, you use the .Address property of that range.
Yep, you’re right: it works just like it should. The answer to the original post is to remove the equal sign. In other words,
TextBox1.ControlSource = "=Data!a4"
is incorrect; it will try to use the string that is in cell A4 as the control source address. It should be
TextBox1.ControlSource = "Data!a4"
This illustrates a good technique for getting detailed information about how a property should be used. For example, try setting the property manually if possible (by typing into the property sheet) until you get it to work, then inspect the result:
Debug.Print frmForm1.txtBox1.ControlSource
This really beats trying to code it the way you thought it should work and beating your head against the wall.
When you get old like me
, sometime you just can’t see
I set it manually in the properties window, viewed it in the watch window, then changed it incorrectly with an extra equal sign, “=Sheet!Range”. To make matters worse, the range had a string in it which just happened to be a valid address, “L10”, so I was like Clancy on the RTA (you have to be old to get that)
–Sam
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.
Notifications