hi!
ich möchte aus einer matrix das grösste element einer zeile bestimmen und dann die komplette zeile und spalte, in der das element sich befindet löschen.
hat einer eine idee ?
vielen dank
olli
Welche Zeile und welche Spalte soll gelöscht werden?
Gruß- Micha
PS: Rückmeldung wäre nett.
AW: matrix
16.03.2006 21:48:35
Ramses
Hallo
probiers mal so OptionExplicit
Sub Delete_Matrix_Max() Dim srcRange As Range Dim fndRange AsVariant Dim delRow As Long, delCol AsLong Set srcRange = Range("A1:Z100") Set fndRange = srcRange.Find(Application.WorksheetFunction.Max(srcRange)) IfNot fndRange IsNothingThen With fndRange delRow = .Row delCol = .Column EndWith Columns(delCol).Delete Rows(delRow).Delete EndIf EndSub
hi rainer,
sorry...aber was mache ich mit dem programmcode?
bin nicht so fit in VB... :-(
AW: matrix
16.03.2006 22:02:18
Ramses
Hallo
vorher
C
D
E
F
G
H
10
Artikel
1
2
3
4
5
11
1
2
2
2
11
1
12
2
0
-
2
7
4
13
3
1
2
-
8
1
14
4
4
3
0
9
1
15
5
2
4
1
0
-
Code laufen lassen OptionExplicit
Sub Delete_Matrix_Max() Dim srcRange As Range Dim fndRange AsVariant Dim startRow As Long, endRow AsLong Dim startCol As Long, endCol AsLong startRow = 11 endRow = 15 startCol = 4 endCol = 8 Set srcRange = Range(Cells(11, 4), Cells(15, 8)) Set fndRange = srcRange.Find(Application.WorksheetFunction.Max(srcRange)) IfNot fndRange IsNothingThen Range(Cells(fndRange.Row, startCol), Cells(fndRange.Row, endCol)).ClearContents Range(Cells(startRow, fndRange.Column), Cells(endRow, fndRange.Column)).ClearContents EndIf EndSub
Nachher
C
D
E
F
G
H
10
Artikel
1
2
3
4
5
11
1
12
2
0
-
2
4
13
3
1
2
-
1
14
4
4
3
0
1
15
5
2
4
1
-
Gruss Rainer
Anzeige
AW: matrix
16.03.2006 22:03:54
Ramses
Hallo
VB-Editor starten "Alt"+"F11"
Modul einfügen
Code reinkopieren
Ansicht - Symbolleisten - Formular
Schaltfläche auf die Tabelle ziehen
Das Makro zuweisen
Fertig
Gruss Rainer
AW: matrix
16.03.2006 22:44:35
olli
jo...super...soweit klappts :-)
vielleicht noch eine kleinigkeit... ist es schwierig, den programmcode so abzuwandeln, das man sich die zeile, in der er das grösste elementfinden soll auswählen kann?
das wäre noch die krönung...bin euch jetzt schon super dankbar....
also z.b. nimm die 2. zeile der matrix, suche dass grösste element und lösche die zeile und spalte.
AW: matrix
16.03.2006 22:58:16
Ramses
Hallo
Vorher den Bereich markieren, dann laufen lassen.
C
D
E
F
G
H
10
Artikel
1
2
3
4
5
11
1
12
2
0
-
2
4
13
3
1
2
-
1
14
4
4
3
0
1
15
5
2
4
1
-
Gruss Rainer
Anzeige
Sorry,... hier der Code
16.03.2006 22:59:10
Ramses
Hallo
Bereich markieren, dann Code laufen lassen OptionExplicit
Sub Delete_Matrix_Max() Dim srcRange As Range Dim fndRange AsVariant Dim startRow As Long, endRow AsLong Dim startCol As Long, endCol AsLong startRow = 11 endRow = 15 startCol = 4 endCol = 8 Set srcRange = Range(Selection.Address) Set fndRange = srcRange.Find(Application.WorksheetFunction.Max(srcRange)) IfNot fndRange IsNothingThen Range(Cells(fndRange.Row, startCol), Cells(fndRange.Row, endCol)).ClearContents Range(Cells(startRow, fndRange.Column), Cells(endRow, fndRange.Column)).ClearContents EndIf EndSub