Anzahl Zeichen in Excel zählen

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

Rumborak
Posts: 3
Joined: 25 Aug 2022, 07:23

Anzahl Zeichen in Excel zählen

22 Sep 2023, 07:48

Hallo Zusammen,

ich habe ein Excel in deren Spalte A ein x drinnen steht. Allerdings mit Unterbrechung z.B.:
y
x
x
y
y
x
y

Gibt es eine Möglichkeit die Anzahl der x'e zu zählen, die ohne unterbrechung sind? Also oben begonnen, wäre das dann die Anzahl 2.

Danke und Grüße, Thomas
Ahk_fan
Posts: 237
Joined: 31 Aug 2018, 14:34
Contact:

Re: Anzahl Zeichen in Excel zählen

22 Sep 2023, 08:01

in Excel mit ZÄHLENWENN
2023-09-22 14_57_53-Mappe1 - Excel.png
2023-09-22 14_57_53-Mappe1 - Excel.png (12.9 KiB) Viewed 901 times
oder siehe hier:
viewtopic.php?f=76&t=105825&p=470045&hilit=excel+count#p470045

in deinem Fall sieht es so aus:

Code: Select all

xl := ComObjActive("excel.application")
lstrw := xl.Range("A" xl.Rows.Count).End(-4162).Row
anz := 0
loop, %lstrw%
{
	if xl.Range("A" A_Index).Value = "x" 
		anz += 1 
}
msgbox % "anz x: " anz  " letze Zeile" lstrw
regards,
AHK_fan :)
https://hr-anwendungen.de
User avatar
flyingDman
Posts: 2832
Joined: 29 Sep 2013, 19:01

Re: Anzahl Zeichen in Excel zählen

22 Sep 2023, 11:52

So wie ich es verstehe, möchten Sie die längste ununterbrochene Reihe von „x“ in Spalte A zählen. Versuchen Sie Folgendes:

Code: Select all

xl := ComObjActive("excel.application")
max := 0, cnt := 0
for c in xl.Intersect(xl.range("A:A"), xl.ActiveSheet.UsedRange)
	cnt := (c.value = "x") ? (++cnt, max := max(max, cnt)) : 0

msgbox % max
14.3 & 1.3.7

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: Bing [Bot] and 28 guests