Vai al contenuto principale

Come convertire il testo nella casella di testo nel contenuto della cella in Excel?

Se ci sono alcune caselle di testo in un foglio e desideri convertire il contenuto delle caselle di testo in celle separatamente come mostrato nell'immagine sottostante, ci sono modi rapidi per risolvere questo lavoro tranne che per inserire uno per uno in Excel? In questo articolo, presento una macro per farti un favore su questo problema.
doc converte la casella di testo nella cella 1

Converti il ​​contenuto della casella di testo in una cella con VBA


freccia blu freccia destra Converti il ​​contenuto della casella di testo in una cella con VBA

Ad eccezione del codice macro, non esiste alcun trucco che possa convertire rapidamente le caselle di testo in contenuto di celle.

1. Stampa Alt + F11 tasti per abilitare Microsoft Visual Basic, Applications Edition finestra.

2. Clic inserire > Moduli, quindi incolla il codice sottostante nel file Moduli script.

VBA: converti le caselle di testo in cella

Sub TextboxesToCell()
'UpdatebyExtendoffice20160918
    Dim xRg As Range
    Dim xRow As Long
    Dim xCol As Long
    Dim xTxtBox As TextBox
    
    Set xRg = Application.InputBox("Select a cell):", "Kutools for Excel", _
                                    ActiveWindow.RangeSelection.AddressLocal, , , , , 8)
    xRow = xRg.Row
    xCol = xRg.Column
    
    For Each xTxtBox In ActiveSheet.TextBoxes
        Cells(xRow, xCol).Value = xTxtBox.Text
        xTxtBox.Delete
        xRow = xRow + 1
    Next
    
End Sub

doc converte la casella di testo nella cella 2

3. Stampa F5 tasto per eseguire il codice, viene visualizzata una finestra di dialogo per ricordare di selezionare una cella per esportare il contenuto della casella di testo. Vedi screenshot:
doc converte la casella di testo nella cella 3

4. Clic OK. Ora tutte le caselle di testo sono state convertite in contenuto di celle.
doc converte la casella di testo nella cella 4

Suggerimento: sopra VBA rimuoverà le caselle di testo dopo l'esecuzione, se si desidera mantenere le caselle di testo, modificare il codice xTxtBox.Elimina a 'xTxtBox.Delete.

Estensione:Se desideri convertire rapidamente tra numero e testo, prova a utilizzare Kutools per Excel Converti tra testo e numero come mostrato nello screenshot seguente. È piena funzionalità senza limitazioni in

Kutools for Excel, con oltre 300 funzioni utili, rende il tuo lavoro più facile. 
giorni, si prega di scaricare e avere una prova gratuita ora.
doc converte la casella di testo nella cella 5

I migliori strumenti per la produttività in ufficio

🤖 Assistente AI di Kutools: Rivoluziona l'analisi dei dati basandosi su: Esecuzione intelligente   |  Genera codice  |  Crea formule personalizzate  |  Analizzare i dati e generare grafici  |  Richiama le funzioni di Kutools...
Funzioni popolari: Trova, evidenzia o identifica i duplicati   |  Elimina righe vuote   |  Combina colonne o celle senza perdere dati   |   Round senza formula ...
Super ricerca: VLookup a criteri multipli    VLookup a valori multipli  |   VLookup su più fogli   |   Ricerca fuzzy ....
Elenco a discesa avanzato: Crea rapidamente un elenco a discesa   |  Elenco a discesa dipendente   |  Elenco a discesa a selezione multipla ....
Gestore di colonna: Aggiungi un numero specifico di colonne  |  Sposta colonne  |  Attiva/disattiva lo stato di visibilità delle colonne nascoste  |  Confronta intervalli e colonne ...
Funzionalità in primo piano: Messa a fuoco della griglia   |  Vista di progettazione   |   Grande barra delle formule    Gestore di cartelle di lavoro e fogli   |  Resource Library (Testo automatico)   |  Date picker   |  Combina fogli di lavoro   |  Crittografa/decrittografa le celle    Invia e-mail per elenco   |  Super filtro   |   Filtro speciale (filtro grassetto/corsivo/barrato...) ...
I 15 migliori set di strumenti12 Testo Strumenti (aggiungi testo, Rimuovi personaggi, ...)   |   50+ Grafico Tipi (Diagramma di Gantt, ...)   |   40+ Pratico Formule (Calcola l'età in base al compleanno, ...)   |   19 Inserimento Strumenti (Inserisci il codice QR, Inserisci immagine dal percorso, ...)   |   12 Conversione Strumenti (Numeri in parole, Conversione di valuta, ...)   |   7 Unisci e dividi Strumenti (Combina righe avanzate, Celle divise, ...)   |   ... e altro ancora

Potenzia le tue competenze di Excel con Kutools per Excel e sperimenta l'efficienza come mai prima d'ora. Kutools per Excel offre oltre 300 funzionalità avanzate per aumentare la produttività e risparmiare tempo.  Fai clic qui per ottenere la funzionalità di cui hai più bisogno...

Descrizione


Office Tab porta l'interfaccia a schede in Office e semplifica notevolmente il tuo lavoro

  • Abilita la modifica e la lettura a schede in Word, Excel, PowerPoint, Publisher, Access, Visio e Project.
  • Apri e crea più documenti in nuove schede della stessa finestra, piuttosto che in nuove finestre.
  • Aumenta la produttività del 50% e riduce ogni giorno centinaia di clic del mouse!

 

Comments (15)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I am using this script (thanks by the way), but i am trying to get it so that it populates a specific cell and not ask for a cell input each time. what would I change so that it auto populates for example cell B2.

Cheers
This comment was minimized by the moderator on the site
Hi, just change the script
Set xRg = Application.InputBox("Select a cell):", "Kutools for Excel", _
                                    ActiveWindow.RangeSelection.AddressLocal, , , , , 8)

to
Set xRg = Application.Range("B2")

you will insert textbox contents from cell B2
This comment was minimized by the moderator on the site
Hi, sunny. I want a solution in excel. I have copied and pasted a web page containing data. in that, each text box contains some numbers. I am unable to convert it as a regular number in an excel cell containing a particular column. I am using excel 2007.Your text to link
This comment was minimized by the moderator on the site
Hi, sunny. I want a solution in excel. I have copied and pasted a web page containing data. in that, each text box contains some numbers. I am unable to convert it as a regular number in an excel cell containing a particular column. I am using excel 2007.
This comment was minimized by the moderator on the site
hi, I tried in Excel365 and it doesn't work, I get the popup and then I fill in but then nothing happens, thanks for the help, Michel
This comment was minimized by the moderator on the site
Hi, Michel, I have tested the code in Excel 365, it works correctly. Could you give me a picture about your Excel version like this (File > Account)https://www.extendoffice.com/images/stories/comments/sun-comment/Excel_version.png, and the picture about your textboxes contents?
This comment was minimized by the moderator on the site
No me funcionó. Hago todo lo señalado y no pasa nada después de apretar enter. Intenté algunos cambios en la programación y tampoco
This comment was minimized by the moderator on the site
Hi, Juan, there is no Enter key mentioned in the method above, copy and paste the vba, then press F5 key or click the Run button to enable the code.
This comment was minimized by the moderator on the site
Muchas gracias! Buen aporte. Me ayudó mucho.
This comment was minimized by the moderator on the site
Okay, I have Textbox inside Textbox that need to be extracted.
This comment was minimized by the moderator on the site
VBA not working?!
This comment was minimized by the moderator on the site
It works perfectly here. What happen while you running the code? It changes nothing? If you could, please describ more about your data and problem. Thank you.
This comment was minimized by the moderator on the site
I have many Boxes in different sheets, There are 4 sheets which are having particular events on particular day and i would like to take that text boxes of particular day to new sheet combined for that day, How it works i have no idea how to get that data from 4 different sheet to one sheet.
This comment was minimized by the moderator on the site
Not working here either. Select destination cell, click OK, and nothing happens.
This comment was minimized by the moderator on the site
I have tried it in Win10 Excel2016 and Win8 Excel2010, it works both. What working enviroment you use?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations