Textbox when activecell is changed

Certified

Board Regular
Joined
Jan 24, 2012
Messages
179
Hi,

I have about 300 rows and 12 columns of Data.

As a test, I created a text box to display certain items from a row.

Code:
    Sheets("qry_Template_Upload").Shapes("textbox 1").Visible = True
    Sheets("qry_Template_Upload").Shapes("textbox 1").TextFrame.Characters.Text = Testarray(2, 1) & " " & Testarray(2, 2) & _
    Chr(13) & "BU: " & Testarray(2, 16) & _
    Chr(13) & "Entity Sponsor(1): " & Testarray(2, 14) & "  " & "Entity Sponor(2): " & Testarray(2, 15) & _
    Chr(13) & "Status: " & Testarray(2, 3) & Chr(13) & "Direct Ownership: " & Testarray(2, 7) & Chr(13) & "Pickup% " & Testarray(2, 9) & _
    Chr(13) & "Voting Interest: " & Testarray(2, 17) & _
    Chr(13) & "Consolidation: " & Testarray(2, 11) & Chr(13) & "Equity: " & Testarray(2, 12) & Chr(13) & "Comments: " & Chr(13) & Testarray(2, 13)

I was wondering is there a way to get the information displayed in "textbox1" to update as the cursor moves throughout the sheet?

For instance, if the cursor is in row 33 then the array would change to "Testarray(33,...)." and if the cursor is then moved to row 55, the array would update to "Testarray(55,....)"

I have searched the forum but I haven't found anythinhg. Is this even possible?
 

Some videos you may like

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

bugmonsta

Board Regular
Joined
Dec 17, 2013
Messages
214
I set this to update the textbox on SheetSelectionChange, it displays the row and column number in a text box, so you can change it to what ever you would like :)

Code:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
ActiveSheet.Shapes("textbox 1").TextFrame.Characters.Text = "Testarray(" & ActiveCell.Row & "," & ActiveCell.Column & ")"
End Sub

typing that so many times is a pain so reduce it down to something like this maybe:

Code:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim r, c As Integer
    r = ActiveCell.Row
    c = ActiveCell.Column
    ActiveSheet.Shapes("textbox 1").TextFrame.Characters.Text = "Testarray(" & r & "," & c & ")"
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,122,496
Messages
5,596,502
Members
414,073
Latest member
Contilly

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top