Borrar filtros
Borrar filtros

how to extract specific columns using loops?

3 visualizaciones (últimos 30 días)
kumud alok
kumud alok el 21 de Abr. de 2016
Editada: kumud alok el 21 de Abr. de 2016
i have data matrix of 453 rows and 55 columns. i want to extract columns of year '10-11' from excel sheet and want to write matlab file using xlswrite function..i have done this in vba programming but i don't know how to do it in matlab.AS i m working in health data..so i want to apply this code in all 19 districts and extract columns of year'10-11', '11-12', '12-13', '13-14', '14-15'.
this is my vba code:
Sub Button1_Click() Dim sh1 As Worksheet, sh2 As Worksheet Dim col As Long, rng As Range, c As Range, cRng As Range, cRws As Long, col2 As Long
Set sh1 = Sheets("Sheet1")
Set sh2 = Sheets("Sheet2")
With sh1
col = .Cells(1, .Columns.Count).End(xlToLeft).Column
Set rng = .Range(.Cells(1, 1), .Cells(1, col))
For Each c In rng.Cells
If c Like "*13-14*" Then
cRws = .Cells(.Rows.Count, c.Column).End(xlUp).Row
Set cRng = .Range(.Cells(1, c.Column), .Cells(cRws, c.Column))
cRng.Copy sh2.Cells(1, sh2.Columns.Count).End(xlToLeft).Offset(, 1)
End If
Next c
End With
sh2.Columns("A:A").EntireColumn.Delete Shift:=xlToLeft
sh2.Cells.EntireColumn.AutoFit
End Sub
i want to apply the same logic in matlab..i have tried but failed...please help me

Respuestas (0)

Categorías

Más información sobre Data Import from MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by