Preskoči na glavno vsebino

Kako pretvoriti besedilo v besedilnem polju v celico v Excelu?

Če je na listu nekaj besedilnih polj in želite vsebino v besedilnih poljih pretvoriti ločeno v celice, kot je prikazano na sliki spodaj, ali obstajajo kakšni hitri načini za reševanje tega opravila, razen vnosa enega za drugim v Excelu? V tem članku predstavljam makro, ki vam bo naredil uslugo pri tej težavi.
doc pretvori besedilno polje v celico 1

Vsebino besedilnega polja pretvorite v celico z VBA


puščica modri desni mehurček Vsebino besedilnega polja pretvorite v celico z VBA

Razen makro kode ni nobenega trika, s katerim lahko hitro pretvorite besedilna polja v celico.

1. Pritisnite Alt + F11 tipke za omogočanje Microsoft Visual Basic za aplikacije okno.

2. klik Vstavi > Moduliin nato prilepite spodnjo kodo v Moduli skripta.

VBA: Pretvori besedilna polja v celico

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 pretvori besedilno polje v celico 2

3. Pritisnite F5 za zagon kode se odpre pogovorno okno, ki vas opomni, da izberete celico za izvoz vsebine besedilnega polja. Oglejte si posnetek zaslona:
doc pretvori besedilno polje v celico 3

4. klik OK. Zdaj so vsa besedilna polja pretvorjena v vsebino celic.
doc pretvori besedilno polje v celico 4

Namig: zgoraj VBA bo po zagonu odstranil besedilna polja, če želite obdržati besedilna polja, spremenite kodo xTxtBox.Delete do 'xTxtBox.Delete.

razširitev:Če želite hitro pretvoriti med številom in besedilom, poskusite uporabiti Kutools za Excel Pretvori med besedilo in številko kot je prikazano na naslednjem posnetku zaslona. Popolnoma deluje brez omejitev

Kutools za Excel, z več kot 300 priročne funkcije, vam olajša delo. 
dni, prosim prenesite in si zagotovite brezplačno preskusno različico zdaj
doc pretvori besedilno polje v celico 5

Najboljša pisarniška orodja za produktivnost

🤖 Kutools AI Aide: Revolucionirajte analizo podatkov na podlagi: Inteligentna izvedba   |  Ustvari kodo  |  Ustvarite formule po meri  |  Analizirajte podatke in ustvarite grafikone  |  Prikličite funkcije Kutools...
Priljubljene funkcije: Poiščite, označite ali identificirajte dvojnike   |  Izbriši prazne vrstice   |  Združite stolpce ali celice brez izgube podatkov   |   Krog brez formule ...
Super iskanje: Več kriterijev VLookup    Multiple Value VLookup  |   VLookup na več listih   |   Nejasno iskanje ....
Napredni spustni seznam: Hitro ustvarite spustni seznam   |  Odvisni spustni seznam   |  Večkrat izberite spustni seznam ....
Upravitelj stolpcev: Dodajte določeno število stolpcev  |  Premakni stolpce  |  Preklop stanja vidnosti skritih stolpcev  |  Primerjaj obsege in stolpce ...
Predstavljene funkcije: Mrežni fokus   |  Pogled oblikovanja   |   Velika vrstica formule    Upravitelj delovnih zvezkov in listov   |  Knjižnica virov (Samodejno besedilo)   |  Izbirnik datuma   |  Združite delovne liste   |  Šifriranje/dešifriranje celic    Pošljite e-pošto po seznamu   |  Super filter   |   Poseben filter (filter krepko/ležeče/prečrtano ...) ...
15 najboljših kompletov orodij12 Besedilo Orodja (dodajanje besedila, Odstrani znake,...)   |   50 + Graf Vrste (Gantt Chart,...)   |   40+ Praktično Formule (Izračunajte starost glede na rojstni dan,...)   |   19 vstavljanje Orodja (Vstavite kodo QR, Vstavi sliko s poti,...)   |   12 Pretvorba Orodja (Številke v besede, Pretvorba valut,...)   |   7 Spoji in razdeli Orodja (Napredne kombinirane vrstice, Razdeljene celice,...)   |   ... in več

Napolnite svoje Excelove spretnosti s Kutools za Excel in izkusite učinkovitost kot še nikoli prej. Kutools za Excel ponuja več kot 300 naprednih funkcij za povečanje produktivnosti in prihranek časa.  Kliknite tukaj, če želite pridobiti funkcijo, ki jo najbolj potrebujete...

Opis


Kartica Office prinaša vmesnik z zavihki v Office in poenostavi vaše delo

  • Omogočite urejanje in branje z zavihki v Wordu, Excelu, PowerPointu, Publisher, Access, Visio in Project.
  • Odprite in ustvarite več dokumentov v novih zavihkih istega okna in ne v novih oknih.
  • Poveča vašo produktivnost za 50%in vsak dan zmanjša na stotine klikov miške za vas!

 

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