Select text in cell

gallen

Well-known Member
Joined
Jun 27, 2011
Messages
2,016
Hello,

I have a feeling this is very simple but having searched can't find any help on this.

Basically I want to set focus back to a specific cell (easy enough) and then select the content of the cell.

I can't work out how to put the cursor inside the cell and select all the text it contains.

Any suggestions?

Thank you
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi,

Welcome to the board.

Please try the below code

Code:
Sub SelectCell()
   Range("A1").Select
   Range("A1").Copy
   Range("C1").PasteSpecial xlPasteAll
End Sub
 
Upvote 0
I think you will need to provide a little more information. You do not have to put the cursor inside the cell nor do you have to physically have to select any text in the cell in order to obtain the text. You can use the Value property or the Value2 property or maybe even the Text property directly... it kind of depends on what type of information is in the cells and what you want to do with it once you have it. Can you give us a little more detail about your setup and what you are hoping to do with it?
 
Upvote 0
Yes sorry. I'll try to be clearer.

I am validating data using VBA instead of the built-in data validation.

If the data is invalid I need to set focus back to the cell and select the text so that if they move off the cell again the worksheet_change event is triggered
 
Upvote 0
Code:
[COLOR="Blue"]Sub[/COLOR] SelectText()
    Application.SendKeys "{F2}+{HOME}"
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,224,578
Messages
6,179,652
Members
452,934
Latest member
mm1t1

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
Back
Top