Skip to main content

Conas colúin iomlána a scriosadh bunaithe ar luach ceanntásca in Excel?

In a lán cásanna, b’fhéidir go mbeidh ort na colúin iomlána a scriosadh bunaithe ar luach ceanntásca in Excel. Mar shampla, ní mór duit gach colún ina bhfuil luach “sean” sa cheanntásc a scriosadh. Sa rang teagaisc seo, taispeánfaimid modhanna duit chun colúin iomlána a scriosadh bunaithe ar luach ceanntásca i mionsonraí.

Scrios na colúin iomlána bunaithe ar luach ceanntásca le cód VBA
Scrios na colúin iomlána bunaithe ar luach ceanntásca le Kutools for Excel


Scrios na colúin iomlána bunaithe ar luach ceanntásca le cód VBA

Is féidir leat colúin iomlána a scriosadh bunaithe ar luach ceanntásca le cód VBA. Déan mar a leanas le do thoil.

1. Brúigh Eile + F11 eochracha ag an am céanna chun an Feidhmchlár Bunúsach Amharc Microsoft fhuinneog.

2. Sa Feidhmchlár Bunúsach Amharc Microsoft fuinneog, cliceáil Ionsáigh > Modúil. Agus ansin cóipeáil agus greamaigh an cód thíos i bhfuinneog an Mhodúil.

Cód VBA: scrios na colúin iomlána bunaithe ar luach ceanntásca

Sub DeleteSpecifcColumn()
	Set MR = Range("A1:D1")
	For Each cell In MR
		If cell.Value = "old" Then cell.EntireColumn.Delete
	Next
End Sub

nótaí:

1) sa chód, “d'aois"Is é an luach ceanntásca ar mhaith leat an colún iomlán a scriosadh bunaithe air. Athraigh do luach ceanntásca de láimh le do thoil. Agus A1: D1 an raon colún is mian leat a úsáid.
2) Tá an cód seo cás-íogair.

3. Brúigh an F5 eochair chun an cód a rith, scriosfar an colún iomlán le ceanntásc atá cothrom leis an téacs sonraithe láithreach.


Scrios na colúin iomlána bunaithe ar luach ceanntásca le Kutools for Excel

Le Kutools le haghaidh Excel'S Roghnaigh Cealla Sonracha fóntais, is féidir leat gach colún ina bhfuil an luach ceanntásca áirithe a roghnú ar dtús, agus ansin na colúin roghnaithe seo a scriosadh ag an am céanna. Déan mar a leanas le do thoil.

Roimh iarratas a dhéanamh Kutools le haghaidh Excel, Le do thoil é a íoslódáil agus a shuiteáil ar dtús.

1. Roghnaigh an raon ina bhfuil na colúin a chaithfidh tú a scriosadh, agus ansin cliceáil Kutools > Roghnaigh > Roghnaigh Cealla Sonracha. Féach an pictiúr:

2. Sa Roghnaigh Cealla Sonracha bosca dialóige, roghnaigh an Colún iomlán rogha sa Cineál roghnúcháin alt, agus sa Cineál sonrach liosta anuas, roghnaigh Cothrom rogha, ansin clóscríobh an luach ceanntásca sa bhosca seo a leanas. Agus ar deireadh cliceáil ar an OK cnaipe. Féach an pictiúr:

3. Cliceáil ar an OK cnaipe i mbosca dialóige aníos eile, ansin roghnaítear na colúin ina bhfuil luach ceanntásc sonraithe láithreach.

4. Cliceáil ar dheis ar cheanntásc an cholúin de cholún roghnaithe, agus ansin cliceáil Scrios ón roghchlár cliceáil ar dheis. Ansin scriostar gach colún roghnaithe ag an am céanna.

  Más mian leat triail saor in aisce (30 lá) a bheith agat ar an bhfóntas seo, cliceáil le do thoil chun é a íoslódáil, agus ansin téigh chun an oibríocht a chur i bhfeidhm de réir na gcéimeanna thuas.

Uirlisí Táirgiúlachta Oifige is Fearr

🤖 Kutools AI Aide: anailís sonraí a réabhlóidiú bunaithe ar: Forghníomhú Chliste   |  Gin Cód  |  Cruthaigh Foirmlí Saincheaptha  |  Anailís a dhéanamh ar Sonraí agus Cairteacha a Ghin  |  Feidhmeanna Kutools a agairt...
Gnéithe Coitianta: Faigh, Aibhsigh nó Aithnigh Dúblaigh   |  Scrios Sraitheanna Bána   |  Comhcheangail Colúin nó Cealla gan Sonraí a Chailleadh   |   Babhta gan Foirmle ...
Cuardaigh Super: Ilchritéir VLookup    VLookup Illuachanna  |   VLookup Trasna Ilbhileoga   |   Amharc doiléir ....
Liosta anuas Casta: Go tapa Cruthaigh Liosta Anuas   |  Liosta anuas Cleithiúnach   |  Liosta Buail Isteach Ilroghnacha ....
Bainisteoir Colún: Cuir Líon Sonrach Colún leis  |  Colúin Bog  |  Scoránaigh Stádas Infheictheachta na gColún Ceilte  |  Déan comparáid idir Raonta & Colúin ...
Gnéithe Réadmhaoin: Fócas Eangaí   |  Amharc Dearaidh   |   Barra Mór na Foirmle    Leabhar Oibre & Bainisteoir Bileog   |  Leabharlann Acmhainní (Uaththéacs)   |  Piocálaí Dáta   |  Comhcheangail Bileoga Oibre   |  Criptigh/Díchriptigh Cealla    Seol Ríomhphost trí Liosta   |  Scagaire Super   |   Scagaire Speisialta (scagaire trom/iodálach/stailc tríd...) ...
Barr 15 Uirlisí12 Téacs uirlisí (Cuir Téacs, Bain Carachtair,...)   |   50 + Cairt cineálacha (Cairt Gantt,...)   |   40+ Praiticiúil Foirmlí (Ríomh aois bunaithe ar lá breithe,...)   |   19 Insertion uirlisí (Cuir isteach Cód QR, Ionsáigh Pictiúr ón gCosán,...)   |   12 Tiontú uirlisí (Uimhreacha le Focail, Comhshó Airgeadra,...)   |   7 Cumaisc & Scoilt uirlisí (Sraitheanna Comhcheangail Casta, Cealla Scoilt,...)   |   ... agus eile

Supercharge Do Scileanna Excel le Kutools le haghaidh Excel, agus Éifeachtúlacht Taithí Cosúil Ná Roimhe. Kutools le haghaidh Excel Tairiscintí Níos mó ná 300 Ardghnéithe chun Táirgiúlacht a Treisiú agus Sábháil Am.  Cliceáil anseo chun an ghné is mó a theastaíonn uait a fháil ...

Tuairisc


Tugann Tab Oifige comhéadan Tabbed chuig Office, agus Déan Do Obair i bhfad Níos Éasca

  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
Comments (13)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi, I need to delete a load of columns containing # in the headings - my understanding of VBA is very limited and the report has about 60 columns. The # is not always in the same location in each heading, so I need to identify any columns with the # in the heading and remove those columns. Is anyone able to guide me on this please?

I also need to split the report into 3 sections - the data runs across the worksheet (ie column A - H is Sales invoices; column I-Z is Purchase invoices and column AA-AG is Payments - each of these need to go onto a seperate worksheet - it is very labour intensive doing this manually so I am hoping someone can help me in VBA with this one as well.

Thanks
This comment was minimized by the moderator on the site
Hola, tengo una hoja de excel con varios datos, digamos 4 columnas y 12 filas, me gustaría poder imprimir cada fila en un folio separado en una plantilla, es decir, tenemos una hoja con varios nombres y apellidos y teléfono, quiero imprimir tantas páginas como filas tenga la hoja de excel, he inte tado varias cosas pero no encuentro la forma. Gracias de antemano
This comment was minimized by the moderator on the site
Hi,
If you want to print each row in a separate page in the worksheet, here is a suggestion that you insert page breaks every 1 row and then print them.
Methods provided in this article may do you a favor. Please have a try. Thank you.
How To Insert Page Break Every X Rows In Excel?[/url]
https://www.extendoffice.com/documents/excel/1774-excel-insert-page-break-every-row.html
This comment was minimized by the moderator on the site
The VBA example states that the code will delete all columns whose headers CONTAIN "old." That is not the case. The = operator will only delete exact matches. You need to use the LIKE operator with a wildcard.
Fixed code:Sub DeleteSpecifcColumn()
Set MR = Range("A1:D1")
For Each cell In MR
If cell.Value LIKE "old*" Then cell.EntireColumn.Delete
Next
End Sub

This comment was minimized by the moderator on the site
Hi,Thank you for your correction and sharing. 
This comment was minimized by the moderator on the site
Hi, is it possible to do this with multiple column names?
This comment was minimized by the moderator on the site
What if the headers are starting from 4th row
This comment was minimized by the moderator on the site
Hi Mark,
Try the below code. In the eighth line, please enclose each column name with double quotes and separate them by comma. Hope I can help. Thank you.

Sub DeleteSpecifcColumn()

Dim xFNum, xFFNum, xCount As Integer

Dim xStr As String

Dim xArrName As Variant

Dim MR, xRg As Range

On Error Resume Next

Set MR = Range("A1:N1")

xArrName = Array("old", "new", "get") 'enclose each column name with double quotes and separate them by comma

xCount = MR.Count

xStr = xArrName(xFNum)

For xFFNum = xCount To 1 Step -1

Set xRg = Cells(1, xFFNum)

For xFNum = 0 To UBound(xArrName)

xStr = xArrName(xFNum)

If xRg.Value = xStr Then xRg.EntireColumn.Delete

Next xFNum

Next

End Sub
This comment was minimized by the moderator on the site
I think line 12 needs to be changed to get the code to work. Original line 12 "Set xRg = Cells(1, xFFNum)" modified line 12 "Set xRg = MR(1, xFFNum)"
Sub DeleteSpecifcColumn()
Dim xFNum, xFFNum, xCount As Integer
Dim xStr As String
Dim xArrName As Variant
Dim MR, xRg As Range
On Error Resume Next
Set MR = Range("A1:N1")
xArrName = Array("old", "new", "get") 'enclose each column name with double quotes and separate them by comma
xCount = MR.Count
xStr = xArrName(xFNum)
For xFFNum = xCount To 1 Step -1
Set xRg = MR(1, xFFNum)
For xFNum = 0 To UBound(xArrName)
xStr = xArrName(xFNum)
If xRg.Value = xStr Then xRg.EntireColumn.Delete
Next xFNum
Next
End Sub
This comment was minimized by the moderator on the site
Hey! This works well until you have two contiguous columns with the same header. Say your range is A1:A5, and A2 and A3 have the header 'old'. It will delete A2, but then the A3 will move to the place A2 used to occupy, and the code will skip it, as it will be looking at the new A3, the next cell on its range.
This comment was minimized by the moderator on the site
Hi Elias,
As you mentioned, A2 and A3 have he same header "old". But they are in the same column, after applying the code, the whole column A will be removed immediately.
I am not sure I get your point. Would be nice if you could provide screenshot of what you are trying to do.
This comment was minimized by the moderator on the site
Sorry if this seems super basic but this is my first time trying vba. Using this how would I apply it to delete multiple column headers. I am actually trying to only keep certain header columns and delete the rest of a changing list.
This comment was minimized by the moderator on the site
In the first code just copy the 4th row and change the "old" into the second column name and it will work
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations