View Full Version : Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)
DocAElstein
10-19-2021, 03:15 PM
Some extra notes in support of this Thread post:
https://www.dsl-forum.de/threads/25111-speedport-w504v-nicht-kommunizieren-online-verbunden/page2?p=169630&viewfull=1#post169630
Einige zusätzliche Hinweise zur Unterstützung dieses Thread-Beitrags:
https://www.dsl-forum.de/threads/25111-speedport-w504v-nicht-kommunizieren-online-verbunden/page2?p=169630&viewfull=1#post169630
Kopien einiger der fehlenden Frageposts
Copies of some of the missing initial question posts
Speedport W504V - kann nicht kommunizieren. Online, verbunden, aber antwortet nicht auf 192.168.2.1 oder https://speedport.ip in der Adressleiste
( DSL alles in Ordnung, aber nur 4 grün licht beleuchtet und keine funktionieren Telefon oder Internet
Hello
Ich bin zum ersten Mal hier und meine Muttersprache ist nicht Deutsch, also gehen Sie bitte schonend mit mir um, und ich entschuldige mich im Voraus für fehlerhafte Posting-Protokolle :)
Ich habe schon oft einige ähnliche forumsbeitrag durchgelesen, beispielsweise:
https://www.dsl-forum.de/threads/18403-speedport-w504v-nicht-ansprechbar?p=120241#post120241
https://www.dsl-forum.de/threads/18403-speedport-w504v-nicht-ansprechbar?p=120241#post120241
https://www.dsl-forum.de/threads/21258-speedport-w504v-kein-zugriff-mehr-moeglich
https://www.dsl-forum.de/threads/21258-speedport-w504v-kein-zugriff-mehr-moeglich
Sie scheinen um das Problem herumzureden, kamen aber nie zu einer vollständigen Lösung.
Jetzt habe ich das gleiche Problem und suche Hilfe
Das spezifische aktuelle Problem:
Mein Router, ein Speedport W504V, verbindet sich erfolgreich mit jedem meiner Computer.(WLAN oder LAN kable)
Verschiedene Dinge bestätigen mir, dass die Speedport W504V die IP-Adresse 192.168.2.1 hat, wie es sollte.
Verschiedene Dinge und Leute haben bestätigt, dass mit dem DSL-Anschluss alles in Ordnung ist.
Verschiedene Dinge deuten darauf hin, dass ich online bin und eine funktionierende DSL-Verbindung habe.
Ich habe nie bewusst versucht, interne Einstellungen des Routers zu ändern
Aber das Problem:
_ Internet (und Telefon) funktioniert jetzt nicht. (Es hat für viele Jahre zuvor funktioniert)
_ beim IP 192.168.2.1 oder https://speedport.ip in die Adresszeile eingebe, kommt nur "Fehler: Netzwerk-Zeitüberschreitung - Der Server unter speedport.ip braucht zu lange, um eine Antwort zu senden." Egal mit welchem Browser oder Computer, ( und ich habe viele Computern und Browsers ).
Einige allgemeinere Hintergründe/ wie das Problem entstanden ist
Für etwa 10 Jahr habe ich eine Speedport W504V als teil meine Haupt Festnetz DSL Flatrate Internet Haus Anschluss Auftrag mit Deutscher Telekom
Meist war es zuverlässig. Wenn alles gut funktioniert, funktionieren Telefon und Internet und alle 5 grünen Lichter am Speedport W504V Leuchten: Von links nach rechts werden diese grünen Lichter wie folgt angezeigt:
Power *
DSL *
Online *
WLAN *
Telefon *
In der Vergangenheit es trat oft ein ähnliches Problem auf, aber im **Durchschnitt nur einmal in der Woche: Internet und Telefon funktionierten nicht mehr. Fast immer, wenn dies geschah, das letzte Licht, das Telefon licht, leuchtete nicht mehr. Es werden also nur 4 der 5 Lichter angezeigt.
(Ich habe noch nie eine andere Situation erlebt, außer
_ dass alle 5 Lichter aufleuchten, wenn alles funktioniert,
oder
_ nur die ersten 4 Lichter aufleuchten, wenn Telefon und Internet verloren gehen).
( ** aber ich betone im Durchschnitt: Manchmal kann es ein paar Mal in der Woche passieren, manchmal kann es nur einmal im Monat passieren)
Normalerweise wird das Problem behoben, indem man den Stecker aus dem Router (Telekom Speedport W504V) zieht, 30 Sekunden wartet und dann wieder verbindet. Meist klappt es beim erste versuche, konnte aber mal das bis eine Stunde und mehrerer versuche bis alles wieder gut war – Aber eine lange Pause ohne Internet und Telefon war eine Ausnahme
Zunehmend seit etwa die letzte 2 Monaten, war es langer bis die „Stecker raus, warten, Stecker rein Lösung“ funktioniert. Also öfter mal eine Pause im Internet und Telefon. Es trat ein paar Stunden auf, dann war es ein paar Mal für einen Tag weg und das neueste Problem, das ist noch seit fast zwei Woche. Also mit dem Speedport bin ich jetzt in die 4 grün licht keine Internet oder Telefone zustand jetzt dauernde.
Mein erster Hilferuf ging an die Telekom. Es folgten viele Telefon- und E-Mail-Gespräche mit verscheiedener Leute von Telekom. Viele von ihnen haben die Telefonleitung überprüft - alles gut - in ihren Worten: Alle Versuche, die "Synchronisation" zu überprüfen, sagen ihnen, dass die Leitung in Ordnung ist. Verscheiedener Leute von Telekom können auch von ihrem Ende aus , aus der Ferne sehen, wenn ich das "stecker raus, warten, stecker rein" mache.
Aber sie können nicht verstehen, warum ich nicht mit meinem Speedport W 504V kommunizieren kann.
Also gaben sie auf.
Der Speedport W504V ist mein Router - ich habe ihn bei der Telekom gekauft, nicht gemietet. Es ist außerhalb der Garantiezeit und sie wollten es sowieso nicht ersetzen.
Ich miete jetzt einen neuen Router von Telekom. ( FRITZ!Box 7590 ). Es funktioniert .. meistens hab ich Internet an manche meine Computern , aber auch nicht ohne einige neue Probleme - aber das ist ein separates Thema.
Zu meiner eigenen Zufriedenheit würde ich gerne weiterhin sehen, ob ich den Speedport W504V wieder zum Laufen bringen kann, weil, in Zukunft könnte ich viel mehr auf ein funktionierendes Internet angewiesen sein und von zu Hause aus arbeiten, daher möchte ich so viel Kontrolle und Verständnis dafür haben.
Telekom nützt mir in dieser Speedport W 504V Frage / Probleme nichts mehr.
Kann mir hier jemand etwas zum Ausprobieren empfehlen?
Bitte, ich bin ein Laie mit fast keinen Computerkenntnissen. Aber ich bin lernbegierig. Ich habe Computer mit XP, Vista, Windows 7 und Windows 10 für mich verfügbar. Ich bin mit den älteren Betriebssystemen vertrauter, aber ich kann alle Vorschläge mit jedem System ausprobieren, aber ich bräuchte aufgrund meiner begrenzten Computerkenntnisse klare Anweisungen.
Außerdem: Bitte verzeihen Sie mir und denken Sie nicht, dass ich Sie ignoriere, wenn ich lange brauche, bis ich antworte. Ich habe derzeit nur eingeschränkten Zugang zum Internet. Aber ich werde hier auf jeden Fall häufig nachsehen und so schnell wie möglich Antworten geben. Aber das kann dauern
Danke
Alan Elston
( PS Eine Sache, ich bin mir nicht sicher, ob das relevant sein könnte. Telekom sagt mir, dass mein Anschluss ein dynamischer / automatischer ist: Wenn ich die neue Fritzbox anschließe, bekomme ich VDSL aus der festnetz ; Wenn ich den älteren Speedport anschließe, wird es automatisch auf geschaltet gib das langsamere DSL aus der festnetz
PS 2 Hier der Link zu meiner diesbezüglichen Frage im Telekom Hilfeforum:
https://telekomhilft.telekom.de/t5/Telefonie-Internet/Ich-kann-keinen-Ausfall-unseres-Telefon-und-Internet-Festnetzes/td-p/5342695
https://telekomhilft.telekom.de/t5/Telefonie-Internet/Ich-kann-keinen-Ausfall-unseres-Telefon-und-Internet-Festnetzes/td-p/5342695
** Es ist Gelöst markiert, ist aber nicht gelöst , meine Meinung nach )
Edit PS 3 Eine letzte Sache, etwas Seltsames. Ich verwende manchmal ein kostenpflichtiges VPN. ( hide.me über OpenVPN oder SoftEther ). In der Vergangenheit, als ich die "4 nur Lichter kein Internet- oder Telefon problem" hatte, passierte oft etwas Seltsames. Wenn ich einen Computer über VPN verbunden hatte, dann hatte dieser Computer noch einige Zeit einen funktionierenden Internetzugang. Bei meinem aktuellen Problem hatte ich immer noch Internet auf einem Computer über SoftEther für zwei Tage in dem aktuellen Langzeitproblem!!! - Wenn ich während dieser Zeit das VPN auf diesem Computer trennte, hatte ich ohne VPN kein Internet. Durch das erneute Verbinden dieses Computers über VPN hatte ich wieder ein funktionierendes Internet
( Ich sollte hier auch sagen, dass ich bei meinen verschiedenen Experimenten zur Lösung des Problems manchmal alle Computer getrennt und ausgeschaltet habe. Das hat mir nicht geholfen das Problem zu lösen
)
DocAElstein
10-19-2021, 03:24 PM
Some extra notes in support of this Thread post:
https://www.dsl-forum.de/threads/25111-speedport-w504v-nicht-kommunizieren-online-verbunden/page2?p=169630&viewfull=1#post169630
Einige zusätzliche Hinweise zur Unterstützung dieses Thread-Beitrags:
https://www.dsl-forum.de/threads/25111-speedport-w504v-nicht-kommunizieren-online-verbunden/page2?p=169630&viewfull=1#post169630
Kopien einiger der fehlenden Frageposts ( Nicht komplete )
Das sind nur einige meiner groben Notizen
Copies of some of the missing initial question posts ( Not complete )
They are just some of my rough notes
Beispiels: ....... mit dem Speedport W 504V wird es ab Montag nicht mehr funktionieren, da dieser kein VDSL verarbeiten kann. https://telekomhilft.telekom.de/t5/Telefonie-Internet/Ich-kann-keinen-Ausfall-unseres-Telefon-und-Internet-Festnetzes/m-p/5350381/highlight/true#M1390337
....... Die Leitung schaltet sich Montag automatisch rauf und lässt sich nicht mehr stoppen. Der VDSL-Port ist variabel und schaltet sich runter, damit dein Speedport 504V das auch packt https://telekomhilft.telekom.de/t5/Telefonie-Internet/Ich-kann-keinen-Ausfall-unseres-Telefon-und-Internet-Festnetzes/m-p/5352431/highlight/true#M1390697
Vielleicht die Frage anders stellen. Sagen wir, ich habe einen perfekten, voll funktionsfähigen Speedport W504V. (Ich werde wahrscheinlich in ein oder zwei Tagen haben, weil ich ein paar bei ebay vorgestern gekauft habe)
Das hätte vor ein paar Wochen bei meinem bisherigen Telekom DSL 16.000 RAM IP funktioniert
Ich habe jetzt VDSL 50. Ich weiß, dass die Fritzbox funktioniert, (meistens)
Aber wird irgendwo etwas zurückfallen, Rückfall oder sonst was zaubern, damit ein Speedport noch funktioniert.
Einige Leute bei der Telekom haben mir gesagt, dass es so sein wird. Einige waren anderer Meinung. Telekom wissen es also nicht!
Hi Broesel
Danke für die Antwort.
deine Lan-Verbindungen an der Frizbox 7590 (Netzwerkkabel-Verbindungen) funktionieren ja laut deiner Beschreibung.--
Gerade jetzt scheint die Fritz Box 7590 auf den meisten meiner Computer korrekt zu funktionieren und bietet ein stabiles Internet über WLAN oder LAN.
Daran möchte ich jetzt noch nichts machen, bin aber natürlich daran sehr interessiert, eventuell gegen Ende der Woche noch einmal zu experimentieren, also werde ich dann jeden Vorschläge ausprobieren.
... funktioniert aber nur wenn du SSID und WLAN-Schlüssel deines Speedport W 504 V "nie geändert" hast.
Schau mal auf die Rückseite/Unterseite deines Speedport W 504 V....
Ich hatte es neu gekauft, es hat noch nie jemand etwas geändert, und zum Beispiel nutze ich die WLAN-Info auf die Rückseite, wenn ich nach Passwörtern usw. gefragt werde. Das alles hat immer funktionieret mit dem info von die Rückseite
Zu den Einstellungen an der Fritz Box 7590:
Ich verstehe nicht allzu viel über die technischen Details der Einstellungen. Nach einigem Herumspielen am vor letzten Wochenende, als ich es ausgepackt und zum ersten Mal angeschlossen habe, hat es irgendwann beim LAN Verbindung kable zu einer meine Laptops , einen automatischen Einrichtungsvorgang gestartet, den ich laufen gelassen habe, und einfach alle vorgeschlagenen Einstellungen belassen und auf "Weiter" klicken "-Taste, bis es fertig war (Die ganze Geschichte hier: https://telekomhilft.telekom.de/t5/Telefonie-Internet/Ich-kann-keinen-Ausfall-unseres-Telefon-und-Internet-Festnetzes/m-p/5352210/highlight/true#M1390641 )
Am Ende des Prozesses wurden mir diese Informationen präsentiert:
https://i.postimg.cc/HW8m5XYb/Fritzbox-fertig-einrichtung.jpg
https://i.postimg.cc/sDFrJxxq/Fritzbox-fertig-einrichtung.jpg
https://i.postimg.cc/jdzr3TJ5/Fritzbox-fertig-einrichtung.jpg
Gleichzeitig begann das Internet auf allen bisher angeschlossenen Computern voll zu funktionieren
...Du könntest z.B. die SSID und den WLan-Schlüssel deines Speedport W 504 V auf die Fritzbox 7590 übertragen (umschreiben).
Das speichern nicht vergessen......
So mach ich es immer wenn ich mal einen anderen WLan-Router benutze und i.d.R. klappt das auch.
Das merk ich z.B. daran wenn bei uns zu Hause niemand meckert.
gerade benutze und experimentiere nur ich mit Dingen, daher denke ich, dass ich die Dinge vorerst so lassen werde, wie sie sind, aber das könnte eine Idee für später sein, danke für den Vorschlag.
....
Am besten auf Verschlüsselungsstärke WPA/WPA2. Dein Speedport und die Fritzbox können das.
Ich bin mir nicht sicher, wie ich das machen würde. Vielleicht habe ich diese Einstellung schon? - hier wird ein WPA2 angezeigt https://i.postimg.cc/HW8m5XYb/Fritzbox-fertig-einrichtung.jpg
Alan
Hi
Ja, ich vermutete auch, dass die Situation einigermaßen günstig war, mir einen VDSL-Vertrag zu unterjubeln.
Aber nach 10 Jahren habe ich erwartet, dass es an der Zeit sein könnte, ein wenig zu aktualisieren, zumal ich in ein paar Monaten zu Hause möglicherweise mehr beschäftigt und auf ein gutes Internet angewiesen bin.
Vielleicht war das Mieten des Modems/Routers im Nachhinein keine so gute Idee. Ich hatte nicht gedacht, dass ich sie so günstig kaufen kann. Auf der anderen Seite sollte ich bei einem gemieteten Gerät bessere Hilfe erwarten, wenn ich irgendwelche Probleme habe, die mit dem Modem/Router zusammenhängen könnten.
Mein alter Vertrag ( DSL 16.000 ) hat 35 Euro komplett im Monat gekostet. Anscheinend habe ich den Speedport gekauft - ich erinnere mich jetzt nicht mehr. Der neue Vertrag ist auf 35 Euro für 6 Monate festgelegt, danach kostet er 40 Euro pro Monat. Der Vertrag hat eine Mindestlaufzeit von 24 Monaten, was der übliche Deal ist. Die FRITZ!Box 7590 kostet 8 Euro monatlich, 12 Monate Mindestmietdauer.
Vielleicht hätte ich einen besseren Deal machen können, aber wenn sich die Fritzbox beruhigt und ich das verbleibende seltsame Problem lösen kann, das bei einigen meiner Computer festgestellt wurde, dann werde ich vielleicht die Dinge so lassen, wie sie sind.
Ich denke, ein Speedport W723V ist für VDSL in Ordnung, und sie scheinen genauso billig zu sein wie ein Speedport W504V bei ebay. Vielleicht werde ich mir also ein paar davon kaufen, nur um es in den nächsten Tagen zum Spaß auszuprobieren.
....dein W504 hat definitiv KEINEN variablen Schalter und wird an einem VDSL-Anschluß nicht funktionieren. ....
Ich habe mich wohl nicht ganz klar erklärt. Was ich meinte war, dass einige Leute bei der Telekom vorgeschlagen haben, dass sich die automatische Umschaltung in einer nahegelegenen Box befindet, wahrscheinlich was ich nahe meinem neresten Nachbar gesehen habe: Vor einigen Jahren tauchte neben der alten kleineren eine viel größere Telekom-Box auf. Bei Recherchen im Internet sieht es so aus:
https://de.wikipedia.org/wiki/Very_High_Speed_Digital_Subscriber_Line
https://i.postimg.cc/qhWstCrv/290px-Junction-boxes-Deutsche-Telekom.jpg (https://postimg.cc/qhWstCrv)
Was ich dachte, verstanden zu haben, war, dass sich der Switch in dieser Box befindet und es irgendwie bermerkt , welchen Router ich habe und das gelieferte Signal entsprechend auf DSL oder VDSL ( https://telekomhilft.telekom.de/t5/Telefonie-Internet/Ich-kann-keinen-Ausfall-unseres-Telefon-und-Internet-Festnetzes/m-p/5352431/highlight/true#M1390697 …… Der VDSL-Port ist variabel und schaltet sich runter, damit dein Speedport 504V das auch packt. Also einfach laufen lassen und alles wird gut ….. )
Aber vielleicht habe ich das nicht richtig verstanden.
Jedenfalls haben einige andere bei der Telekom gesagt, dass es keine Chance gibt, dass der Speedport W504V jetzt für mich funktioniert.
Die Informationen, die ich habe, sind also unsicher.
Meine Vermutung eines ungebildeten Laien, basierend auf meinen jüngsten Experimenten, ist, dass ich seit der "Umstellung" vor einer Woche keinen Speedport W504V niemals verwenden könnten , auch wenn er einwandfrei funktionierte so wie er soll.. Ich begründe diese Schlussfolgerung auf folgendem: Seit dem "Schalter" vor einer Woche verhält es sich meind speedport W504V anders:
Wie zuvor leuchten das erste grüne Licht ( Power ) und das vierte grüne Licht ( WLAN ) dauerhaft. Aber jetzt das grüne DSL-Licht blinkt ständig und das grüne OnLine-Licht geht nie an. ( Vorher hatte ich die Situation wie in meinem beschrieben hier (https://www.dsl-forum.de/threads/25111-speedport-w504v-nicht-kommunizieren-online-verbunden?p=169535&viewfull=1#post169535) – entweder 4 oder 5 grün licht dauende an.
So wie ich es verstehe, bzw. vermute, deutet ein endlos blinkendes DSL-Licht darauf hin, dass es versucht, Kontakt aufzunehmen, aber nie dort ankommt, oder einige Worte in diesem Sinne.
Hello Hardwaremensch.
Ich wollte dich nicht wieder mit einer langen Geschichte langweilen, aber wie du fragst...
…WARUM willst du ihn widerrufen?
Ich bin mir noch nicht sicher, ob ich das machen will, aber wenn ja, muss ich es in den nächsten Tagen tun
Welchen Vertrag hast du denn,
Ich verstehe nicht allzu viel von , aber Du kannst von hier aus sehen,
https://telekomhilft.telekom.de/t5/Telefonie-Internet/Ich-kann-keinen-Ausfall-unseres-Telefon-und-Internet-Festnetzes/m-p/5346069/highlight/true#M1389675
dass Deutscher Telekom mir sagen, dass ich das früher hatte
DSL 16.000 RAM IP ( mit das evtl. jetzt defekt Speedport W504V Typ A )
Und jetzt anscheinend das habe
VDSL 50 und einer FRITZ!Box 7590
Aus einigen anderen Vertrag Papierkram sehe ich, dass ich sie hatte „Magenta Zuhaus S“
Download: Max. 16 MBit/s, Normal 9,5 MBit/s, Min. 6,304 MBit/s
Upload: Max. 2,4 MBit/s, Normal 1,5 MBit/s, Min. 0,704 MBit/s
Und jetzt das neue Vertrag, was ich evtl. widerrufen ist „Magenta Zuhaus M“ VDSL 50
Download: Max. 50 MBit/s, Normal 47 MBit/s, Min. 27,9 MBit/s
Upload: Max. 10 MBit/s, Normal 9,4 MBit/s, Min. 2,7 MBit/s
DocAElstein
10-19-2021, 03:25 PM
Some extra notes in support of this Thread post:
https://www.dsl-forum.de/threads/25111-speedport-w504v-nicht-kommunizieren-online-verbunden/page2?p=169630&viewfull=1#post169630
Einige zusätzliche Hinweise zur Unterstützung dieses Thread-Beitrags:
https://www.dsl-forum.de/threads/25111-speedport-w504v-nicht-kommunizieren-online-verbunden/page2?p=169630&viewfull=1#post169630
Kopien einiger der fehlenden Frageposts ( Nicht komplete )
Das sind nur einige meiner groben Notizen
Copies of some of the missing initial question posts ( Not complete )
They are just some of my rough notes
Und WARUM willst du ihn widerrufen?
Wenn ich das tue, hat das mehrere Gründe:
_ Im Nachhinein denke ich, dass etwas mehr Zeit hätte investieren müssen, um zu sehen, ob das anfängliche Problem mit dem Speedport aus den in meinem letzten beitrag (https://www.dsl-forum.de/threads/25111-speedport-w504v-nicht-kommunizieren-online-verbunden?p=169547&viewfull=1#post169547) genannten Gründen behoben werden könnte
_ Ich habe keine Leistungs- / Geschwindigkeitsverbesserung bemerkt (aber ich gestehe, ich verstehe nicht genug, um gründlich zu testen, und ich kann die Systeme nicht vergleichen, da ich jetzt nur das eine System habe.)
_ Ich war nicht allzu beeindruckt von der Unterstützung, die ich von der Telekom hatte. Es wurde variiert: widersprüchliche Informationen, falsche Informationen oder oft keine Informationen, das heißt manchmal auch keine Antworten. Die verschiedenen Hotlines haben sich als fast so nutzlos erwiesen wie die ausländischen Callcenter, die manche Unternehmen nutzen. Das ist mir derzeit weniger wichtig, aber in ein paar Monaten bin ich vielleicht viel stärker auf einen zuverlässigen Internet zu Hause angewiesen. Der neue Vertrag hat eine Laufzeit von 24 Monaten, den vorherigen könnte ich in ca. einem Drittel dieser Zeit kündigen, wenn ich entscheide, dass die Telekom kein verlässlicher Partner für mich ist.
_ Wenn wir vorerst davon ausgehen, dass mein aktuelles Problem auf ein Problem mit meinem Speedport zurückzuführen ist, ist das neue System viel weniger zuverlässig: Früher hatte ich in den letzten 10 Jahren nur selten Internetverluste. Bisher schlägt das neue System etwa 30 % der Zeit im Internet aus. Das Problem tritt zeitweilig auf und kommt von selbst wieder, aber es nützt nicht viel, wenn ich ein kontinuierliches Internet möchte oder später brauche
_ Auf einigen meiner Computer habe ich ein neues Problem, sie akzeptieren den Netzwerkschlüssel nicht.
( https://telekomhilft.telekom.de/t5/Telefonie-Internet/Ich-kann-keinen-Ausfall-unseres-Telefon-und-Internet-Festnetzes/m-p/5352210/highlight/true#M1390641
)
https://i.postimg.cc/0KkF1YRL/XP-Netzwerkschluessel-error.jpg (https://postimg.cc/0KkF1YRL)
Ich bin mir ziemlich sicher, dass dieses neue Problem auf das neue System zurückzuführen ist, da ich es noch nie zuvor gesehen habe, weder zu Hause noch als diese Laptops häufig von zu Hause aus auf vielen verschiedenen Systemen verwendet wurden.
Aber ich werde drüber schlafen und morgen mit klarem Kopf nachdenken
Ich gehe davon aus, dass die Telekom mir sagen würde, dass es entweder schwierig oder unmöglich ist, die Dinge wieder so zu machen, wie sie waren. Ob das stimmt, ist eine andere Frage.
Alan
https://telekomhilft.telekom.de/t5/Telefonie-Internet/Ich-kann-keinen-Ausfall-unseres-Telefon-und-Internet-Festnetzes/m-p/5352431/highlight/true#M1390697
Als ich gestern Abend vor dem Schlafengehen die ausführlichen Anweisungen meines Speedports gelesen habe, sind einige Dinge aufgefallen, die ich möglicherweise übersehen habe.
Mir ist auch gestern aufgefallen, dass man bei ebay einen Speedport W504V sehr günstig ergattern kann: Habe mir heute Morgen gleich einen gekauft, neu, originalverpackt, komplett für 1 Euro. Eines der Kabel oder das Netzteil allein ist das Geld wert, - auch wenn mir der Speedport nicht hilft, habe ich immer noch ein Schnäppchen. ( Netzteil habe ich noch zu prüfen, wie Du vorgeschlagen hast - also bekomm ich bald einen neuen zum Vergleichen)
Man ist immer schlauer danach – ich hätte besser etwas warten hatten vor ich Telekom kontaktiert, evtl. eine neue Speedport erste aus probiert nach eine mehr gründlich Internet recherchieren und gründliches erneutes Lesen der originalen sehr detaillierten Speedport geliefert Anweisungen.
Für das Extra Geld , das ich pro Monat für meinen neuen Vertrag zahle, hätte ich mehrere neue Speedports kaufen können.
Ich persönlich bevorzuge immer mindestens zwei Lösungen gegenüber allem, was mit Computern und Internet zu tun hat. ( Die neue Fritzbox funktioniert noch nicht einwandfrei. )
Die bessere Lösung für mich könnte sein, zwei Speedports zum Laufen zu bringen, dann kann ich beim nächsten Problem leichter erkennen, was / wo das Problem ist. Ich bin mir immer noch nicht 100% sicher, dass mein Problem nur der Router ist/war, obwohl es bei weitem am wahrscheinlichsten ist. Es könnte aber auch eine seltsame Interaktion mit meinem VPN sein, die etwas im Speedport durcheinander gebracht hat. - Ein paar Mal, als Internet und Telefon zuvor einige Stunden abwesend waren, hatte ich den Verdacht, dass es nach dem Ausschalten eines Computers, der damals über VPN verbunden war, wieder aufkam war. Aber ich konnte mir damals nicht sicher sein.
Mal schauen was meine Wochenende experimentieren bringt. Ich habe noch ein paar Tage Zeit, um vom 14-tägigen Vertrag Widerrufs Recht Gebrauch zu machen, denk ich. - damit noch nicht alles verloren ist
Alan
Just testing ….
Nur testen ….
Danke für die Antwort und Meinung Hardwaremensch, vielleicht haben sie Recht. Im Dschungel dessen, was ich geschrieben habe, habe ich schon erwähnt, dass ich bereits einen neuen Router bei der Telekom miete, aber ich denke, ich würde gerne noch eine Weile versuchen, den Speedport als Hintergrundprojekt zum Laufen zu bringen, bevor ich aufgebe, aus den Gründen, die ich schon erwähnt habe.
Ich habe gestern die original Speedport und Auftrag papierkram von 2011 gefunden in meine Dachboden. Dort gibt es viele Informationen, einschließlich verschiedener Informationen zur ursprüngliche Einstellungen und Einrichtung usw. In den nächsten Tagen werde ich das durchlesen und meine allgemeinen internen Recherchen als Hintergrundprojekt fortsetzen.
In den Original papierkram wird erwähnt, dass die Ersteinrichtung zwischen einer bestimmten Zeit an einem bestimmten Tag erfolgen musste, die in diesem Originalstapel von papierkram angegeben hatten. Ich bin mir der Bedeutung dessen nicht sicher. Eventuell könnte ich nochmal versuchen, Hilfe von der Telekom zu bekommen. Telekom scheinen meinen letzten fragen zu ignorieren. Verständlich denke ich. Ein Autoverkäufer ist nicht so daran interessiert, bei der Reparatur Ihres alten Autos zu helfen, besonders nachdem er Ihnen ein neues verkauft ( vermietet in meine fall ) hat!
Ich habe zu Letzt gesehen, dass der Router ein kleines Loch hat, in das ich einen Stift stecken kann, möglicherweise um eine Art Werkseinstellungen wiederherstellen durchzuführen.
Das klingt nach einer drastischen Maßnahme. Ich werde das wahrscheinlich versuchen als letztes, aber ich werde warten, bis ich versucht habe, ein paar weitere Ideen zu bekommen oder mich ein bisschen besser informiert zu haben.
Alan
Danke, Hardwaremensch, dass Du versucht hast, mir (wieder) etwas vernunft einreden, :)
Ich werde sicherlich bedenken, was Du sagst, aber es ist nicht ganz richtig zu sagen, dass ich versuchst auf Biegen und Brechen einen alten Router zum Laufen zu bringen. Ich war nie besonders daran interessiert, es zu reparieren, und ich war seit letztem Samstag nicht mehr in der Nähe eines Routers.
Ich hatte diese Woche nicht viel Zeit für Computer oder Internet. Alles, was ich zu meinem Problem getan habe, war, ein paar Beiträge zu schreiben, ein wenig zu lesen und ich habe ein paar Speedport W504Vs und W723Vs gekauft.
Ich habe sie nur gekauft, weil sie so unglaublich günstig waren,- die Netzteile und das LAN-Kabel sind mehr wert, als ich dafür bezahlt habe. (Es sind viele Kabel und Anschlüsse in dem, was ich gekauft habe, enthalten. Ich bin mitten in einer langfristigen großen Hausrenovierung, die einen großen Computerraum beinhalten soll. Selbst wenn ich alle Router wegwerfe, kann ich das machen gute Verwendung der anderen Kleinigkeiten.)
Ich habe bereits erklärt, dass es für meine zukünftige Arbeit nützlich sein könnte, die Internetsysteme zu verstehen, die ich habe, die ich hatte und die ich haben könnte.
Letzten Samstag habe ich die Fritzbox angeschlossen gelassen. Die paar Male, die ich auf dem Computer war, hat das Internet funktioniert, also sieht es so aus, als ob die Fritzbox ständig funktioniert. Das Surfen im Internet scheint etwas langsam zu laufen, verglichen mit dem, was ich vorher immer vor meinen letzten Problemen hatte. Aber vielleicht ist das nur Zufall und liegt an etwas anderem als der Fritzbox.
Ich werde auf jeden Fall am Wochenende experimentieren, wenn ich Zeit habe, und mich melden, wenn ich neue Erkenntnisse habe.
Zum Beispiel habe ich jetzt eine neue und zwei vorher normal funktionierende 504Vs. Wenn ich also keine davon bekomme, um mir Internet zu verschaffen, dann weiß ich mit einiger Sicherheit, dass die Antwort auf meine letzte Frage Nein ist. Selbst dann bekomme ich vielleicht noch mehr Einblick in warum / ob das Problem im Titel meines Threads - "Speedport W504V - kann nicht kommunizieren"
Ich erwarte nicht, dass die W723Vs in irgendeiner Hinsicht so gut sind wie die Fritzbox ist. Aber wieder einmal waren sie lächerlich billig, und ich denke, sie sollten in einem VDSL 50-System funktionieren, daher könnte es interessant sein zu sehen, wie sie funktionieren, nur zum Vergleich und meine Experimente. Wenn ich zum Beispiel Internet mit ihnen bekomme, haben sie möglicherweise das gleiche Problem wie die Problem Fritzbox mit einigen meiner Computer oder auch nicht. Das könnte mir helfen, herauszufinden, wo das Problem liegt.
Alan
DocAElstein
10-19-2021, 03:31 PM
Some extra notes in support of this Thread post:
https://www.dsl-forum.de/threads/25111-speedport-w504v-nicht-kommunizieren-online-verbunden/page2?p=169630&viewfull=1#post169630
Einige zusätzliche Hinweise zur Unterstützung dieses Thread-Beitrags:
https://www.dsl-forum.de/threads/25111-speedport-w504v-nicht-kommunizieren-online-verbunden/page2?p=169630&viewfull=1#post169630
Kopien einiger der fehlenden Frageposts, bzw fehlenden Thread .. ( https://www.dsl-forum.de/threads/25111-speedport-w504v-nicht-kommunizieren-online-verbunden )
Copy of the final complete answer
Kopie der endgültigen vollständigen Antwort
Hi
Ich habe jetzt Antworten auf alle Fragen aus diesem Thread.. ( https://www.dsl-forum.de/threads/25111-speedport-w504v-nicht-kommunizieren-online-verbunden )
____(i) Die Antwort auf ... antwortet nicht auf 192.168.2.1 oder https://speedport.ip in der Adressleiste … die Hauptfrage des Thread-Titels (https://www.dsl-forum.de/threads/25111-speedport-w504v-nicht-kommunizieren-online-verbunden)war, dass die Software, die für den Einstieg in die Einstellung über einen Browser verantwortlich war, seit lange, einschließlich der Zeit, als der Speedport W504V noch recht aktuell war, nicht funktionierte. Die meisten alten /sehr alten Browser funktionieren. Ich habe dies vermisst, da mir am Telefon von Leuten, die mir halfen, geraten wurde, einen neueren Computer und Browser zu verwenden. Dies ist für die meisten Dinge der beste Rat, aber nicht in diesem speziellen Fall.
Die ganze Geschichte hier:
https://telekomhilft.telekom.de/t5/Geraete-Zubehoer/Speedport-W504V-funktioniert-nicht-mehr-im-Festnetz-keines-davon/td-p/5370149
Ein paar andere Dinge nebenbei, auch die für andere besprochene Dinge relevant sind
__ (ii) Mein neuer Ersatz-Router (FRITZ!Box 7290) funktioniert auf einigen älteren Computern nicht: Antwort: Reduzieren Sie das Router-WLAN-Passwort auf 16 Stellen und ändern Sie das Router-WLAN-Sicherheitsding von WPA2 (CCMP) auf WPA + WPA2, um dieses Problem zu beheben
Die ganze Geschichte hier:
https://eileenslounge.com/viewtopic.php?f=21&t=37237
__(iii) Deutsche Telekom Zugangsdaten und t-online.de E-Mail-Anomalien
Ich habe anfangs aus einem seltsamen Grund viel Zeit verschwendet:
Viele Hilfestellungen der Telekom sind automatisiert. Keine Überraschung da.
Was viele nicht wissen, auch die meisten Telekom-Mitarbeiter, mit denen ich gesprochen habe, ist, dass viele Dinge entweder nicht oder viel schlimmer, sehr irreführend und sprunghaft funktionieren, wenn Sie nicht bei einem bestimmten t-online.de Freemail-Konto eingeloggt sind . Viele Leute wie ich wussten nie, dass ich so einen Account habe. So einen Account wird von der Telekom für Sie gemacht haben. (Dies wurde Ihnen möglicherweise in einer frühen Mitteilung, als Sie zum ersten Mal Telekom-Kunde wurden, im Kleingedruckten mitgeteilt)
Die ganze Geschichte hier:
https://telekomhilft.telekom.de/t5/Telefonie-Internet/Ich-kann-keinen-Ausfall-unseres-Telefon-und-Internet-Festnetzes/m-p/5363073/highlight/true#M1392788
__(iv) Zugangsdaten?? Was ist das? So etwas habe ich noch nie gesehen, Kumpel
Dies hängt teilweise mit __(iii) zusammen.
Es gibt eine aktuelle, teil junge, Generation, die denkt, man steckt Dinge ein und sie werden sich selbst initialisieren usw. Dazu gehören mindestens die Hälfte der Telekom-Leute, mit denen ich gesprochen habe.- Wenn etwas nicht sofort funktioniert, werfen Sie es weg, es muss veraltet sein.
( Ich meine nicht besonders alte Geräte - ich stimme zu, dass mein alter Speedport wahrscheinlich weggeworfen / aktualisiert werden muss. Der Punkt, den ich hier ansprechen möchte, ist ein anderer.)
Beim ersten Versuch, meine neue FRITZ!Box 7290 zu benutzen, hat irgendwann eine automatische Initialisierung stattgefunden, und in meiner Unwissenheit habe ich einfach die Standardeinstellungen "empfohlen" akzeptiert und auf Weiter geklickt.
Wenn man dann in die Internet Zugangsdaten schaut.. sieht man keine. Nichts ist da. Alle Eingabefelder sind leer - Zugangsdaten?? Was ist das? So etwas habe ich noch nie gesehen, Kumpel. Ich habe nie gewusst, was Zugangsdaten sind, und die Hälfte der Leute bei der Telekom weiß es immer noch nicht. Der Schuld liegt an der Standardoption, die vermutlich alle diese Daten rein schreibt, und die neueren FRITZ!Box-Router verbergen es dann vor dir.
Nur um klar zu sein, was ich hier sagen will: Als ich das erste Mal die Fritzbox angeschlossen habe (https://telekomhilft.telekom.de/t5/Telefonie-Internet/Ich-kann-keinen-Ausfall-unseres-Telefon-und-Internet-Festnetzes/m-p/5352210/highlight/true#M1390641) , hat ein automatischer Prozess gestartet und ich hatte ein funktionierendes Internet danach. Ich habe nichts außer Weiter geklickt.
Wenn ich dann in "--Internet -- Zugangsdaten --- "- nachgeschaut habe, dann sehe ich auch nach vielen Neustarts keine Einträge ( https://i.postimg.cc/Y0DysTJf/FRITZ-Box-7590-After-first-automatic-working-internet-no-zugansdaten-shown.jpg ).
Mein Laie vermute ist , dass die Fritzbox-Software Dir anzeigt, was Du manuell eingegeben hast. Wenn Du selbst nie etwas eingegeben haben, wird dort nie etwas angezeigt, auch wenn die fritzbox deine Zugangsdaten gespeichert hat.
Dies kann einem Laien helfen, die Informationen zu verbergen, worum es bei den Zugangsdaten geht: Anfangs dachte ich fälschlicherweise, dass eine Fritzbox keine Zugangsdaten braucht.
(Siehe auch hier für detailliertere Screenshots https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=15698&viewfull=1#post15698 )
__(v) Mein größeres Hauptproblem des versagenden Internets.
Ich hatte das Gefühl, dass mein Problem nicht unbedingt mein Router war, und dass möglicherweise die geringeren Probleme, die ich seit dem neuen Vertrag und dem neuen Router hatte, einfach darin bestand, dass alles, was falsch war, einen geringeren Einfluss hat auf die neueres, leistungsfähigeres System. Wenn Du zum Beispiel Mist Benzin von deine örtlichen Tankstelle bekommen, damit deine älteres Auto nicht mehr anspringt, also kaufst Du ein neues Auto und es springt an. Also die Tankstelle sagt dir jetzt ist alles gut - dein altes Auto war das Problem.
Also habe ich den neuen Vertrag gekündigt und konnte aufgrund der Erkenntnisse aus _(iii) einen Techniker der Telekom zu mir nach Hause kommen lassen, um meine Anlage zu überprüfen. ( Dieses Hilfesystem läuft parallel zu anderen Hilfesystemen der Telekom, die meisten Leute in der Telekom wissen es nicht, und es läuft aus einem alten Vertrag mit einer privaten Firma - Eine private Telekommunikationsfirma wurde geschickt).
Der Techniker dachte, es sei mein alter Router, bis ich ihm erklärte ____(i)
Dann suchte er mit verschiedenen Testinstrumenten weiter.
Eine fehlerhafte Verbindung in einer Anschlussdose irgendwo wurde erkannt, ersetzt und mein Internet funktionierte wieder wie in den letzten 10 Jahren meist zuverlässig.
Nur als Interesse zum Schluss…
_ (vi) Ich habe die Gelegenheit genutzt, um ein paar Geschwindigkeiten (mit dem www.breitbandmessung.de-Zeug) zu überprüfen, sowohl in der VDSL 50 Vertragszeit als auch in DSL 16.000 RAM IP Vertragszeit.
Ich habe fast** nie einen Leistungsunterschied mit verschiedenen Routern bemerkt
In der VDSL 50 Vertragszeit hatte ich einen Download durchschnittlich 51 Mbit/s, Upload durchschnittlich 11 Mbit/s
In der Vertragslaufzeit von VDSL 50 kann es bei der Nutzung von Kabel-LAN statt WLAN zum Download um einige Mbit/s-Verbesserungen gekommen sein.
In der DSL 16.000 RAM IP Vertragszeit mag es bei meinem ältesten Router im Vergleich zu den anderen einen sehr geringen Leistungsabfall** gegeben haben, aber wenn überhaupt, dann nur ca. .5 Mbit/s im Upload.
In der DSL 16.000 RAM IP Vertragszeit hatte ich einen Download durchschnittlich 12 Mbit/s, Upload durchschnittlich 2 Mbit/s
Die Geschichte hat also ein Happy End. Ich ärgere mich ein wenig, dass ich so viel selbst machen musste, aber das ist meine Entscheidung, ich hätte es leicht haben können, das System durch das neuere ersetzen und das Gleiche in ein oder zwei Jahren tun, wenn/ falls die fehlerhaft Verbindung probleme wäre schlechter.
Aber ich habe ein bisschen gelernt.
Aufgrund meines angewachsenen Wissens wurde mir plötzlich klar, was mein Schwiegervater mir vor einigen Jahren gegeben hatte: Auf dem Dachboden fand ich die alte FRITZ!Box 3270, die er mir gegeben hatte. Ich konnte es manuell einrichten, und es funktioniert, um mich ins Internet zu bringen.
Ich bin also mit vielen Routern und dem Wissen, was man damit macht, gut eingedeckt.
(Ich werde in ein paar Wochen vielleicht wieder auf das bessere VDSL-System updaten, sobald ich überzeugt bin, dass mein derzeitiger Anschluss in Ordnung ist)
Gruß aus Hof
Alan
DocAElstein
10-20-2021, 12:12 AM
Macro coding for this Thread:
https://excelfox.com/forum/showthread.php/2766-Autofill-Text-if-Criteria-are-met?p=15705&viewfull=1#post15705
Option Explicit
Sub AutoNameFill() ' https://excelfox.com/forum/showthread.php/2766-Autofill-Text-if-Criteria-are-met
Rem 1 Worksheet info
Dim Ws1 As Worksheet: Set Ws1 = ThisWorkbook.Worksheets.Item(1)
Dim Lr As Long: Let Lr = Ws1.Range("A" & Ws1.Rows.Count & "").End(xlUp).Row
Rem original data in first two columns
Dim arrDta() As Variant: Let arrDta() = Ws1.Range("A4:B" & Lr & "").Value2 ' Data range into an array
Rem modifying the data in the array
Dim Rw As Long ' The data line at any time
Dim celVl As String, Nme As String ' the cell value in column 1 at any row , a name
Do While Rw < Lr - 4 ' ----- Main outer loop for all data rows
Do While InStr(1, celVl, "total", vbBinaryCompare) = 0 And celVl <> "Total" ' This keeps us going until we hit a total
Let Rw = Rw + 1: Let celVl = arrDta(Rw, 1) ' next line : cell value in that line
If celVl <> "" Then Let Nme = celVl ' this will store our current name if we have one
If arrDta(Rw, 2) <> "" And InStr(1, arrDta(Rw, 2), "total", vbBinaryCompare) = 0 Then Let arrDta(Rw, 1) = Nme ' we put the name in if there is data in column 2 and not a total this will also get the name total entry but never mind
Loop ' While InStr(1, celVal, "total", vbBinaryCompare) <> 0 ' This keeps us going until we hit a total
' At this point we have reached a total and so will be moving onto the next name section
Let celVl = "" ' this clears the last name total entry
Loop ' While Rw < (Lr-4) ----- Main outer loop for all data rows
Rem Repasting out the modified data
Ws1.Range("A4:B" & Lr & "").Value2 = arrDta()
End Sub
DocAElstein
10-24-2021, 11:31 AM
Copy from here https://www.excelforum.com/excel-programming-vba-macros/343845-docking-project-explorer-vertically.html#post4545938
For help in this post
https://eileenslounge.com/viewtopic.php?p=289070#p289070
Yep Rob Bovey’s sledgehammer is the Doggy’s Nut‘s. Once again saved a lot of frustration. Just now my Immediate Window got “swallowed” and “eaten” as I moved over it whilst moving the position of my VB Editor Window. All I could do was open or close it after that. The problem was that on opening it, it took up all the entire space in the VB Editor but refused to let me reduce its size or move it in any of the ways that it usually is possible to do. ( So maybe the Immediate Window had sort of swallowed the VB Editor ?? ). In any case something had its knickers in a twist, and all the other ways to get the problem sorted had no effect !!
Following the instructions from Rob Bovey sorted it Out
Absolutely spiffing, Jolly Billy Ho! IMO
Alan
P.s. The thread is a bit Old so the exact steps may be a bit different..
Here is one ( almost) current example...
( Using Windows Vista )
_ 1) Close Excel ***
_ 2) Hit the Microsoft symbol bottom left
_ 3) Type in RegEdit in the small search Window
_ 4) Double click on the RegEdit which should now be offered in the larger window just above the Search Window
( _ 5)( At this point I got an “Administrator Rights” type window pop Up – So you might not get past here depending on your “rights” – I got past by just clicking OK in this pop Up ) )
_ 6) A big registry Window pops up – I navigate through HKEY_CURRENT_USER\Software\Microsoft\VBA\6.0\Commo n
_ 7) Now on the right side of the Registry, I see a Dock . I double click on Dock
_ 8) I have now an Edit Window. It has a large “Value:” Box full with Numbers and letters in it.
_ 9) I Highlight all those Numbers and delete them, ( All but 0000 should then vanish ) , then Hit OK
_ 10) – “Jolly Ruddy Spiffing Billy Merry Ho Wonks Bingo !!” . – On opening Excel I find if I hit Ctrl+G from the VB Editor ( Alt+11 ), my immediate Window appears at the bottom of the VB Editor, but I can drag it in and out of the VB Editor anywhere where I Jolly well like! :)
(*** Do not forget that Excel must be closed or it will not work )
RegEditDockingWonks.JPG http://i.imgur.com/V0qttoA.jpg https://i.postimg.cc/X7qkfYdG/Reg-Edit-Docking-Wonks.jpg
494178
3652
https://i.postimg.cc/X7qkfYdG/Reg-Edit-Docking-Wonks.jpg (https://postimg.cc/MvkBxxsq)
P.P.s. May be this Thread could do with being in the Tips and Tutorials Sub Forum?
DocAElstein
11-05-2021, 01:13 PM
In support of this post:
https://www.eileenslounge.com/viewtopic.php?p=289526#p289526
http://www.excelforum.com/excel-programming-vba-macros/1126564-choose-a-folder-and-loop-a-sub.html#post4315748
http://www.excelforum.com/excel-programming-vba-macros/1126751-get-value-function-loop-through-all-files-in-folder-and-its-subfolders.html#post4316662
http://www.mrexcel.com/forum/excel-questions/918955-macro-code-opening-excel-file.html
http://www.excelforum.com/excel-programming-vba-macros/1126860-is-it-possible-to-sum-entire-column-with-out-opening-excel.html
https://eileenslounge.com/viewtopic.php?f=30&t=28616&p=222840#p222840
https://eileenslounge.com/viewtopic.php?f=30&t=28616&p=226939#p226939
https://eileenslounge.com/viewtopic.php?f=30&t=31150&p=241142#p241142
https://eileenslounge.com/viewtopic.php?f=30&t=31784&p=246079#p246079
https://eileenslounge.com/viewtopic.php?f=30&t=31883&p=247028#p247028
https://eileenslounge.com/viewtopic.php?f=30&t=31150&p=241204#p241204
Range referencing with and without $s https://eileenslounge.com/viewtopic.php?p=241197#p241197
https://eileenslounge.com/viewtopic.php?p=271415#p271415
DocAElstein
11-05-2021, 01:13 PM
In support of this post:
https://www.eileenslounge.com/viewtopic.php?p=289526#p289526
http://www.excelforum.com/excel-programming-vba-macros/1126564-choose-a-folder-and-loop-a-sub.html#post4315748
http://www.excelforum.com/excel-programming-vba-macros/1126751-get-value-function-loop-through-all-files-in-folder-and-its-subfolders.html#post4316662
http://www.mrexcel.com/forum/excel-questions/918955-macro-code-opening-excel-file.html
http://www.excelforum.com/excel-programming-vba-macros/1126860-is-it-possible-to-sum-entire-column-with-out-opening-excel.html
https://eileenslounge.com/viewtopic.php?f=30&t=28616&p=222840#p222840
https://eileenslounge.com/viewtopic.php?f=30&t=28616&p=226939#p226939
https://eileenslounge.com/viewtopic.php?f=30&t=31150&p=241142#p241142
https://eileenslounge.com/viewtopic.php?f=30&t=31784&p=246079#p246079
https://eileenslounge.com/viewtopic.php?f=30&t=31883&p=247028#p247028
https://eileenslounge.com/viewtopic.php?f=30&t=31150&p=241204#p241204
Range referencing with and without $s https://eileenslounge.com/viewtopic.php?p=241197#p241197
https://eileenslounge.com/viewtopic.php?p=271415#p271415
DocAElstein
11-09-2021, 01:06 PM
In support of this post
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12783
The ps1 file, and also below the $WindowsSearch.Add_Click(
Share ‘ChrisSearchTweaks18-19July.ps1 https://app.box.com/s/cbs7go8i2tdxw4wguthgxcviecaxjn6b
iex ((New-Object System.Net.WebClient).DownloadString(' https://raw.githubusercontent.com/ChrisTitusTech/win10script/71609526b132f5cd7e3b9167779af60051a80912/win10debloat.ps1'))
$windowssearch.Add_Click({
Write-Host "Disabling Bing Search in Start Menu..."
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Se arch" -Name "BingSearchEnabled" -Type DWord -Value 0
<#
Write-Host "Disabling Cortana"
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Se arch" -Name "CortanaConsent" -Type DWord -Value 0
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Force | Out-Null
}
#>
Write-Host "Hiding Search Box / Button..."
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Se arch" -Name "SearchboxTaskbarMode" -Type DWord -Value 0
Write-Host "Removing Start Menu Tiles"
Set-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -Value '<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <LayoutOptions StartTileGroupCellWidth="6" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <DefaultLayoutOverride>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <StartLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <defaultlayout:StartLayout GroupCellWidth="6" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </StartLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </DefaultLayoutOverride>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <CustomTaskbarLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <defaultlayout:TaskbarLayout>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:TaskbarPinList>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:UWA AppUserModelID="Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdg e" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:DesktopApp DesktopApplicationLinkPath="%APPDATA%\Microsoft\Windows\Start Menu\Programs\System Tools\File Explorer.lnk" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </taskbar:TaskbarPinList>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </defaultlayout:TaskbarLayout>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </CustomTaskbarLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value '</LayoutModificationTemplate>'
$START_MENU_LAYOUT = @"
<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns:taskbar="http://schemas.microsoft.com/Start/2014/TaskbarLayout" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
<LayoutOptions StartTileGroupCellWidth="6" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6" />
</StartLayoutCollection>
</DefaultLayoutOverride>
</LayoutModificationTemplate>
"@
$layoutFile="C:\Windows\StartMenuLayout.xml"
#Delete layout file if it already exists
If(Test-Path $layoutFile)
{
Remove-Item $layoutFile
}
#Creates the blank layout file
$START_MENU_LAYOUT | Out-File $layoutFile -Encoding ASCII
$regAliases = @("HKLM", "HKCU")
#Assign the start layout and force it to apply with "LockedStartLayout" at both the machine and user level
foreach ($regAlias in $regAliases){
$basePath = $regAlias + ":\SOFTWARE\Policies\Microsoft\Windows"
$keyPath = $basePath + "\Explorer"
IF(!(Test-Path -Path $keyPath)) {
New-Item -Path $basePath -Name "Explorer"
}
Set-ItemProperty -Path $keyPath -Name "LockedStartLayout" -Value 1
Set-ItemProperty -Path $keyPath -Name "StartLayoutFile" -Value $layoutFile
}
#Restart Explorer, open the start menu (necessary to load the new layout), and give it a few seconds to process
Stop-Process -name explorer
Start-Sleep -s 5
$wshell = New-Object -ComObject wscript.shell; $wshell.SendKeys('^{ESCAPE}')
Start-Sleep -s 5
#Enable the ability to pin items again by disabling "LockedStartLayout"
foreach ($regAlias in $regAliases){
$basePath = $regAlias + ":\SOFTWARE\Policies\Microsoft\Windows"
$keyPath = $basePath + "\Explorer"
Set-ItemProperty -Path $keyPath -Name "LockedStartLayout" -Value 0
Write-Host "Search and Start Menu Tweaks Complete"
} # This was missing 12 July 2021
})
DocAElstein
11-25-2021, 12:12 PM
Coding for these Threads
https://eileenslounge.com/viewtopic.php?p=290229#p290229
https://excelfox.com/forum/showthread.php/2772-Some-Date-Notes-and-Tests
Option Explicit ' “Window"s is a name for a programming idea which might result in something we “see” as what we conceive as Windows. Manipulating of the actual “Windows” seems the key to pseudo “making my own” InputBox with range selection. Direct linked libraries (dll) are available to run as and when required, hence the wording of direct link: They are used as an efficient means to organise Microsoft’s software generally allowing different Applications to share smaller programs which are shipped as standard with the Microsoft Windows Operating system. They are however also available to programmers , programming the applications. They are usually contained in Folder with name similar to User 32. "API calls”: just means usually that you are using those things and related “Windows” concept-all gets gets bundled up in imprecise intimidating term API, for Application Programming interface
Public Declare Function APIsinUserDLL_MsgBox Lib "user32.dll" Alias "MessageBoxTimeoutA" (Optional ByVal hWnd As Long, Optional ByVal Prompt As String, Optional ByVal Title As String, Optional ByVal uType As Long, Optional ByVal wLanguageID As Long, Optional ByVal Delay_ms As Long) As Long
Private Sub WhatsInMyGlobies() '
Dim WndNumber As Long
APIsinUserDLL_MsgBox hWnd:=WndNumber, Prompt:="Using DateSerial(2021, 12, 1) inside VBA will give" & vbCr & vbLf & vbCr & DateSerial(2021, 12, 1), Title:="NonModalPopUpThingy", uType:=4, wLanguageID:=0, Delay_ms:=5000 ' ' The error will occur if I do not have a pro open so the MsgBox line will error at ProWb.Name
End Sub
Sub MessinMitdates()
Rem 1 Attempt to get the sShortDate from registry via DateSerial( ) implification way
On Error GoTo Bed
Dim TestDateSerial As String
Let TestDateSerial = DateSerial(9, 3, 4) ' DateSerial(year, month, day) https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/dateserial-function
' By experimenting, it appears that for the day and month, if the sShortDate in the registry needs more than one character then a zero is added to that retuned by DateSerial(9, 3, 4) For the year any missing characters seem to be relplaced by a 0 2 or 1 - For this reason I don't use 1 or 2 for the day or month becuse if i do , there may be some wrong determination below: We use the number to determine if we have a day or month or year
If InStr(1, TestDateSerial, "9", vbBinaryCompare) = 0 Then MsgBox Prompt:="You have no Year in your short date format": Exit Sub
If InStr(1, TestDateSerial, "3", vbBinaryCompare) = 0 Then MsgBox Prompt:="You have no Month number in your short date format": Exit Sub
If InStr(1, TestDateSerial, "4", vbBinaryCompare) = 0 Then MsgBox Prompt:="You have no Day number in your short date format": Exit Sub
Dim C As Variant ' This is each character. It can be a number or letter, so I used Variant but string would work also
Dim Cnt As Long: Let Cnt = 1
Let C = Mid(TestDateSerial, Cnt, 1) ' ========= start of returned string
Do While IsNumeric(C) = True
Let Cnt = Cnt + 1 ' we are counting through the characters, (numbers), from the start, while we have a number. So we are counting the first number section
Let C = Mid(TestDateSerial, Cnt, 1)
Loop ' While IsNumeric(C) = True
Dim Cnt1 As Long: Let Cnt1 = Cnt - 1 ' this will be the count of the characters ( numbers ) in the first number section
' =============================================
Dim Sep1 As String
Do While IsNumeric(C) = False
Let Sep1 = Sep1 & C ' In the first seperator
Let Cnt = Cnt + 1 ' we are counting through the character in the thing used as the first seperator. (These should not be numbers)
Let C = Mid(TestDateSerial, Cnt, 1)
Loop ' While IsNumeric(C) = False
Dim DMY As String ' At this point we have reached the end of the first seperator,
' the next lines search the numbers in the first number section to determine if they are a day or month or year
If InStr(1, Left(TestDateSerial, Cnt - 1), "4", vbBinaryCompare) <> 0 Then: Let DMY = "d" ' we are actually looking at the first number and first seperator, but never ming
If InStr(1, Left(TestDateSerial, Cnt - 1), "3", vbBinaryCompare) <> 0 Then Let DMY = "m"
If InStr(1, Left(TestDateSerial, Cnt - 1), "9", vbBinaryCompare) <> 0 Then Let DMY = "y"
Dim sShortDate As String ' the next line gives us a character string where the fist numbers are replaced by characters representing if they are a day or month or year
Let sShortDate = Evaluate("=REPT(""" & DMY & """," & Cnt1 & ")") & Sep1 ' ======= make first bit of output ==
' ===== xx & sep1 ******************************************
Dim Pos2 As Long ' ================================================== ==========================================
Let Pos2 = Len(sShortDate) + 1 ' This should be the position where the second number section starts
Do While IsNumeric(C) = True
Let Cnt = Cnt + 1 ' we are counting the characters ( numbers ) in the second ( middle ) character ( number ) section
Let C = Mid(TestDateSerial, Cnt, 1)
Loop
Dim Cnt2 As Long: Let Cnt2 = Cnt - Pos2 ' this will be the count of the characters ( numbers ) in the second ( middle ) number section
' ========================== at first character in second seperator ========================================
Dim Sep2 As String
Do While IsNumeric(C) = False
Let Sep2 = Sep2 & C '
Let Cnt = Cnt + 1 ' we are counting through the characters making up the second seperator
Let C = Mid(TestDateSerial, Cnt, 1)
Loop ' While IsNumeric(C) = False
' the Cnt C counting stops at the start of the last number section
' the next lines search the numbers in the second ( middle) number section to determine if they are a day or month or year
' at this point we have got the second seperator string, Sep2 and are at the start of the last number ===
If InStr(1, Mid(TestDateSerial, Pos2, Cnt2), "4", vbBinaryCompare) <> 0 Then: Let DMY = "d" ' we are looking in the middle number section
If InStr(1, Mid(TestDateSerial, Pos2, Cnt2), "3", vbBinaryCompare) <> 0 Then Let DMY = "m"
If InStr(1, Mid(TestDateSerial, Pos2, Cnt2), "9", vbBinaryCompare) <> 0 Then Let DMY = "y"
Let sShortDate = sShortDate & Evaluate("=REPT(""" & DMY & """," & Cnt2 & ")") & Sep2 ' this adds to the sShortDate string the characters to indicate the type ( day month or year ) of the middle section numbers and the second seperator
' ==== xx & Sep1 & yy & Sep2 *******************************************
Dim Pos3 As Long: Let Pos3 = Len(sShortDate) + 1 ' this should be the start position of the last number section
Dim Cnt3 As Long '
Let Cnt3 = Len(TestDateSerial) - Pos3 + 1 ' this should be the number of characters ( numbers ) in the last number section
' we don't bother to loop through the last number section
' the next lines search the numbers in the third ( last ) number section to determine if they are a day or month or year
If InStr(1, Mid(TestDateSerial, Pos3, Cnt3), "4", vbBinaryCompare) <> 0 Then: Let DMY = "d" ' we look from the start of the last number section, Pos3 , for a length of its count of its characters , Cnt3
If InStr(1, Mid(TestDateSerial, Pos3, Cnt3), "3", vbBinaryCompare) <> 0 Then Let DMY = "m"
If InStr(1, Mid(TestDateSerial, Pos3, Cnt3), "9", vbBinaryCompare) <> 0 Then Let DMY = "y"
Let sShortDate = sShortDate & Evaluate("=REPT(""" & DMY & """," & Cnt3 & ")") ' finally we add the characters representing the characters to indicate the type ( day month or year ) of the last section
' ===== xx & Sep1 & yy & Sep2 & zzz ************************************************** ***********************
' ================================================== ================================================== =========
GoTo Rem2
Bed: ' Error handling code section for if the above coding errored
Let sShortDate = "Error getting sShortDate"
On Error GoTo -1
Rem2: ' Rem 2 Some other computer and user info
On Error Resume Next ' In case info below is somehow protected
Dim UsrNme As String: Let UsrNme = Application.UserName: Let UsrNme = Environ("username")
Dim CmprNme As String: Let CmprNme = Environ("computername")
Dim WOS As String: Let WOS = Environ("OS")
Dim VersXl As String: Let VersXl = " ( " & ExcelVersion & " ) "
On Error GoTo 0
Rem 3 Shift a space for some info, and some formating
With Worksheets("Dates")
.Range("A1:B15").Insert , shift:=xlShiftDown
.Range("A1:B15").Clear
.Columns("A").Font.Size = 12
.Columns("A").ColumnWidth = 16
.Columns("B").Font.Size = 8
.Columns("B").ColumnWidth = 190
End With
With Worksheets("Dates").Range("A1:B1000")
.Item(1).Value = " " & UsrNme & " " & Format(Now(), "dddd, dd, mmm, yyyy. ") & Format(Now(), "hh") & "hr " & Right(Format(Now(), "hh mm"), 2) & "min" & " " & VersXl
.Item(3).Value = sShortDate: .Item(4).Value = " <---- " & CmprNme & " Registry sShortDate"
.Item(5).Value = DateSerial(2021, 12, 1): .Item(6).Value = "DateSerial(2021, 12, 1) for 1st dec 2021 was assigned to .Value of virgin cell. The .Value of the cell is returned as " & .Item(5).Value & " The .Value2 is returned as " & .Item(5).Value2 & ""
.Item(7).NumberFormat = "m/d/yyyy"
.Item(7).Value = DateSerial(2021, 12, 1): .Item(8) = "DateSerial(2021, 12, 1) for 1st Dec 2021 was assigned to .Value of cell formated in Short Date, using .NumberFormat = ""m/d/yyyy"" The .Value of the cell is " & .Item(7).Value & " The .Value2 is " & .Item(7).Value2 & ""
.Item(7).NumberFormat = "m/d/yyyy"
.Item(9).NumberFormat = "@"
.Item(9).Value = DateSerial(2021, 12, 1): .Item(10) = "DateSerial(2021, 12, 1) for 1st Dec 2021 was assigned to .Value of cell formated in Text, using .NumberFormat = ""@"" The .Value of the cell is " & .Item(9).Value & " The .Value2 is " & .Item(9).Value2 & ""
.Item(9).NumberFormat = "@"
Dim DteSerial As String: Let DteSerial = DateSerial(2021, 12, 1)
.Item(11).Value = DteSerial: .Item(12).Value = "I have not done anything to the format of the cell, its a virgin cell, but I first put what came from DateSerial(2021, 12, 1) into a string variable, DteSerial , and then asigned that string variable to the cell .Value The .Value of the cell is " & .Item(11).Value & " The .Value2 is " & .Item(11).Value2 & ""
.Item(13).NumberFormat = "m/d/yyyy"
.Item(13).Value = DteSerial: .Item(14).Value = "The cell is formattted as short date format using .NumberFormat = ""m/d/yyyy"" I am assigning the filled variable Dteserial to it. The .Value of the cell is " & .Item(13).Value & " the .Value2 is " & .Item(13).Value2 & ""
.Item(13).NumberFormat = "m/d/yyyy"
' Say in a self cancelling meassage box what the DateSerial(2021, 12, 1) returns in VBA
Dim WndNumber As Long:
APIsinUserDLL_MsgBox hWnd:=WndNumber, Prompt:="Using DateSerial(2021, 12, 1) inside VBA will give" & vbCr & vbLf & vbCr & DateSerial(2021, 12, 1), Title:="This will close itself after a few seconds", uType:=4, wLanguageID:=0, Delay_ms:=4000 ' ' The error will occur if I do not have a pro open so the MsgBox line will error at ProWb.Name
DoEvents: DoEvents
.Item(17).Value2 = 44531: .Item(17).NumberFormat = "m/d/yyyy": .Item(18).Value = "a .Value2 of 44531(this is the Excel number for 1stDec,2021) was put in a virgin cell, which then was given the cell format of Short Date, using .NumberFormat = ""m/d/yyyy"" "
.Item(19).Value2 = 44531: .Item(19).NumberFormat = "m\/d\/yyyy": .Item(20).Value = "a .Value2 of 44531 was put in a virgin cell, which then was given the cell format of .NumberFormat = ""m\/d\/yyyy"" "
.Item(21).Value = Format("12 1 2021", "dd_mm_yyyy"): .Item(22).Value = "For a virgin cell I assigned like this .Item(21).Value = Format(""12 1 2021"", ""dd_mm_yyyy"") The .Value frtom the cell is " & .Item(21).Value & " and the .Value2 is " & .Item(21).Value2 & ""
.Item(23).Value = Format(#12/1/2021#, "dd_mm_yyyy"): .Item(24).Value = "For a virgin cell I tried to assign this .Item(23).Value = Format(#12 - 1 .2021#, ""dd_mm_yyyy"") m When I hit Enter I did not get any error, but that was changed to Format(#12/1/2021#, ""dd_mm_yyyy"") What seems to be happeming there is that Excel tries to coerce the string inside a # pair into the standard English American format. So it sees #12/1/2021# as December 1st, 2021 and gives me the date in the format I ask for. The .Value from the cell is " & .Item(23).Value & " and the .Value2 is " & .Item(23).Value2 & ""
.Item(25).Value = Format(#12/1/2021#, "m/d/yyyy"): .Item(26).Value = "For a virgin cell I assigned .Item(25).Value = Format(#12/1/2021#, ""m/d/yyyy"") The .Value from the cell is " & .Item(25).Value & " and the .Value2 is " & .Item(25).Value2 & ""
.Item(27).Value = Format(#12/1/2021#, "m\/d\/yyyy"): .Item(28).Value = "For a virgin cell I assigned .Item(27).Value = Format(#12/1/2021#, ""m\/d\/yyyy"") The .Value from the cell is " & .Item(27).Value & " and the .Value2 is " & .Item(27).Value2 & ""
End With
'_________________________________________________ __________________________________________________ ___________
ThisWorkbook.Save
End Sub
' From Rory's A Tool
Public Function ExcelVersion() As String
Dim temp As String
'On Error Resume Next
#If Mac Then
Select Case CLng(Val(Application.Version))
Case 11: temp = "Excel 2004"
Case 12: temp = "Excel 2008" ' this should NEVER happen!
Case 14: temp = "Excel 2011"
Case 15: temp = "Excel 2016 (Mac)"
Case Else: temp = "Unknown"
End Select
#Else
Select Case CLng(Val(Application.Version))
Case 9: temp = "Excel 2000"
Case 10: temp = "Excel 2002"
Case 11: temp = "Excel 2003"
Case 12: temp = "Excel 2007"
Case 14: temp = "Excel 2010"
Case 15: temp = "Excel 2013"
Case 16: temp = "Excel 2016, 2019 0r 365 (Windows)"
Case Else: temp = "Unknown"
End Select
#End If
#If Win64 Then
temp = temp & " 64 bit"
#Else
temp = temp & " 32 bit"
#End If
Let ExcelVersion = temp
End Function
DocAElstein
12-06-2021, 02:49 PM
In support of this Thread post
https://eileenslounge.com/viewtopic.php?p=290499#p290499
Method a)
This is the way you do it, just in case it is more successful in the future for anything else .
I use here the example of what you are looking for. As you can see, we almost get there, but just crap out at the very last step :(
_1 Go to the Site of the search/ archive engine, web archive org - http://web.archive.org/
That should bring up their “WayBackMachine”
https://i.postimg.cc/XYB2tJgs/Site-web-archive-org.jpg
_ 2 Put that link given from the book in the search bar of their “WayBackMachine”
https://i.postimg.cc/RVFpQGJ5/Put-link-in-search-bar.jpg
3785
_3 Hit Enter
You will then see something like this if it found anything.
https://i.postimg.cc/DZxTzgMv/Lots-of-captures-by-arcaive-Bot.jpg
In this case it seems to have found a lot, - so at this stage it looks very hopeful
_ 4 Pick one of the years where there are hits shown . That is just guess work – try to think of a year that what you are looking for may have been available. In this next screen shot I chose randomly the year 2003
https://i.postimg.cc/ZYjDdXRx/Chose-2003-It-had-a-few-hits-in-it.jpg
Now you will see the dates ringed.
https://i.postimg.cc/q781M5Sn/Ringed-dates-of-when-capture-was-done.jpg
Those are the dates on which the search/ archive engine, web org, made a random capture of the web site
_ 5 Hover over any of them there ringed dates, and click on a time shown
https://i.postimg.cc/hvCyRQw5/Pick-a-date-and-time.jpg
3786
_6 After this you have to take it as it comes and see how far you get.
In this example, I got this, and noticed a link to Examples :
https://i.postimg.cc/3wMLhTSY/Examples-1.jpg
On another attempt after picking a different time and date I got something different but once again found a link to the examples.
https://i.postimg.cc/ncPRd7qs/Examples-2.jpg
3787
When I clicked on either of those links I see this, which is still looking hopeful: We are almost there.
https://i.postimg.cc/mkZXnyd9/Almost-there.jpg
3788
Unfortunately, every attempt so far by me craps out when I hit that zip link
https://i.postimg.cc/PxQVKRMh/Craps-out-at-the-last-attempt.jpg
3789
I tried a couple of dozen times, and so far it always craps out at the last step. Shame we almost got there- I would take a guess that you won’t find the file this way. When I tried the same with the examples for the Excel book, I got the file on about every second attempt.
As I mentioned it’s a bits hit and miss.
I will look again randomly today when I have a few minutes and let you know if I strike lucky. But I don’t hold out much hope in this case.
Always worth a try. More times than not the web archive works for me. I often use it when passing a link to a current web site and pass the link to the archived stored capture in preference to the actual link because then I know they get what I want them to get. Its invaluable for example, for Microsoft links, since they seem to have nothing better to do then change what actually appears at their help links, some times for the better, sometimes for the worse.
Edit
Method b) Frantic net search
Examples.zip - https://app.box.com/s/w75bf0yb8dv875u0myyyg6xxmr9csiw3
RomanWortdBook.dot - https://app.box.com/s/t09e5w0hrr71slos3tlnb5ds9byw5s3p
BobsdBook.doc - https://app.box.com/s/2wwnfuxupruw8jzfmlhlown9trv8yx3t
DocAElstein
12-13-2021, 04:36 PM
In support of this Thread
http://www.eileenslounge.com/viewtopic.php?f=41&t=37540
These were the simple steps:
_ Start at free personal account page,( I did give you before ( https://www.box.com/pricing/individual
https://i.postimg.cc/dtqHX8z3/Choose-free-personal.jpg
https://account.box.com/signup/personal?tc=annual ) )
_ https://i.postimg.cc/vTg6c2KX/box-join-Name-EMail-box-password.jpg
You may have some errors if you do not check all boxes
https://i.postimg.cc/W34ZP16B/error-europe-box-join-Name-EMail-box-password.jpg
https://i.postimg.cc/0yxCrmYm/error2-europe-box-join-Name-EMail-box-password.jpg
_ With all boxes checked , it should be successful
https://i.postimg.cc/nLp70ksc/box-join-sucess-Name-EMail-box-password.jpg
_ by a successful registration, a confirmation Email will be sent to your given Email address
https://i.postimg.cc/RhFLGTDn/They-send-you-an-EMail-confirmation.jpg
The confirmation should arrive at your given Email address, but note it might arrive in spam folder sometimes
https://i.postimg.cc/mZXwk0P3/box-confirmation-may-arrive-in-spam.jpg
_ You must click to confirm your registration
https://i.postimg.cc/x1KMv714/box-confirmation-Verify-EMail.jpg
( _ sometime you may receive a warning from your Email provider, but not always
https://i.postimg.cc/Wzh001dG/box-confirmation-Verify-EMail-Warning.jpg )
_ After you confirmation you should arrive at box login
https://i.postimg.cc/FFdp6hFf/Arrived-at-box-Log-in-page.jpg
_ To login .. first Email address
https://i.postimg.cc/m2n8X0RZ/box-Log-in-EMail.jpg
, then password
https://i.postimg.cc/wjS4vnb4/box-Log-in-password.jpg
_ If all has gone well, you now are logged in to your new account, and can begin using
https://i.postimg.cc/76qVJ419/box-Log-Sucess.jpg
That’s it! You have an account!
_._______________
_ Because I already know all about using, I did skip introduction and set up. But you may chose not to do that
https://i.postimg.cc/Nfs3vhW1/Skipped-Set-up.jpg
_._____________________-
Example Upload and get share link
_New File(s) upload
https://i.postimg.cc/VNqgNvt5/Test-upload-New-File.jpg
( _ you can upload many files at once
https://i.postimg.cc/PrJSMdgF/Upload-many-files-at-once.jpg )
The files will be uploaded
https://i.postimg.cc/ydKfhcKF/Files-will-be-uploaded.jpg
https://i.postimg.cc/HLXZ73qY/All-Files-are-uploaded.jpg
_ I can get a share link quickly
https://i.postimg.cc/YqDscvNH/I-can-get-quick-share-link.jpg
_ I click to copy share link into my clipboard
https://i.postimg.cc/hGQFZ9N6/Copy-share-link-to-Clipboard.jpg
Now that share link is in my clipboard
So finally you have the share link for that File, and can paste it any where
Here is that link:
https://app.box.com/s/gac9uzmfeudlo37hsj4hfim5wb7e3l3z
The peson with that share link can click on it.
Then they will see it and/ or can download it
https://i.postimg.cc/VspVYmYt/I-can-see-it-I-can-download-it.jpg
Alan
Alan
_._____________________-
P.S. For Image posting share links I also use https://postimages.org/
This does not need any registering. I do use this have for example, for all the image links I did use here.
_ start here: https://postimages.org/
_ https://i.postimg.cc/GtNWPKjX/postimages.jpg
_ Select one or more files to upload https://i.postimg.cc/vZwjQc2x/postimages-select-files.jpg
Files will be uploaded
https://i.postimg.cc/MK1wbkhR/post-images.jpg
https://i.postimg.cc/nhKWMpNR/post-images.jpg
_ you can select what type of link you want
https://i.postimg.cc/SsbjdLgN/post-images-uploaded-links-available.jpg
Finally all links are available for you to copy
https://i.postimg.cc/9zHh51qr/post-images-uploaded-links-available.jpg
DocAElstein
01-01-2022, 03:39 PM
In support of this Thread https://excelfox.com/forum/showthread.php/2774-Summarize-Data-from-Dates-to-Months-based-on-Criteria
https://excelfox.com/forum/showthread.php/2774-Summarize-Data-from-Dates-to-Months-based-on-Criteria
https://i.postimg.cc/14gZ3Xtb/Case-Tracker.jpg (https://postimg.cc/14gZ3Xtb)
_____ Workbook: Project Tracker.xlsx ( Using Excel 2007 32 bit )
Row\ColBCD
2DATECONTRACT NO.STATUS
3 01-Jul-21NOT STARTED
4 01-Aug-21IN PROGRESS
5 02-Aug-21COMPLETE
6 09-Sep-21ON HOLD
7 21-Oct-21NOT STARTED
8 22-Oct-21IN PROGRESS
9 03-Nov-21COMPLETE
10 05-Nov-21ON HOLD
11 12-Dec-21COMPLETE
12 22-Dec-21ON HOLD
Worksheet: Case Tracker
https://i.postimg.cc/H87GZZRT/Summary.jpg (https://postimg.cc/H87GZZRT)
_____ Workbook: Project Tracker.xlsx ( Using Excel 2007 32 bit )
Row\ColBCDEF
2DATENOT STARTEDIN PROGRESSON HOLDCOMPLETE
3 Aug-21
4 Sep-21
5 Oct-21
6 Nov-21
7 Dec-21
8 Jan-22
9 Feb-22
10 Mar-22
11 Apr-22
12 May-22
13 Jun-22
14 Jul-22
15 Aug-22
16 Sep-22
17 Oct-22
18 Nov-22
19 Dec-22
Worksheet: Summary
results after running macro here https://excelfox.com/forum/showthread.php/2774-Summarize-Data-from-Dates-to-Months-based-on-Criteria?p=16306&viewfull=1#post16306 https://excelfox.com/forum/showthread.php/2774-Summarize-Data-from-Dates-to-Months-based-on-Criteria?p=16306&viewfull=1#post16306
_____ Workbook: Project Tracker.xls ( Using Excel 2007 32 bit )
Row\ColBCDEF
2DATENOT STARTEDIN PROGRESSON HOLDCOMPLETE
3 Aug-211 1
4 Sep-211
5 Oct-2111
6 Nov-211 1
7 Dec-211 1
8 Jan-22
9 Feb-22
10 Mar-22
11 Apr-22
12 May-22
13 Jun-22
14 Jul-22
15 Aug-22
16 Sep-22
17 Oct-22
18 Nov-22
19 Dec-22
Worksheet: Summary
DocAElstein
02-06-2022, 07:26 PM
In support of the forum post:
NOT POSTED YET – DRAFT COPY
Hi
I am new to PowerShell script since a few weeks
I hit my first major coding problem, I have got over some smaller ones.
I have a GUI with lots of buttons on it. Each Button has some various things behind it. Some do some quite major things to the computer, such as registry changes, others download stuff. With one exception all is working as it should**.
Problem Summary
This coding does what it should. I checked it on a few computers with different Windows 10 versions. It checks for installed winget (https://de.wikipedia.org/wiki/Windows_Package_Manager) on the computer, and if not there attempts to download it. ( That download might not work for other reasons, but that is a separate issue which I am not concerned with here – as it happens I have it installed on all my computers )
On all my current computers that have winget, the message comes up saying 'winget already installed', and the coding moves on. All is well
Write-Host "Checking winget..."
if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe){ # Check if winget is installed
'Winget Already Installed'
}
else{
# Installing winget from the Microsoft Store
Write-Host "Winget not found, installing it now."
$ResultText.text = "`r`n" +"`r`n" + "Installing Winget... Please Wait"
Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget" # If I paste that link in Browser URL I get this offered as if I hit the download button somewhere Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbu ndle
$nid = (Get-Process AppInstaller).Id
Wait-Process -Id $nid
Write-Host Winget Installed
$ResultText.text = "`r`n" +"`r`n" + "Winget Installed - Ready for Next Task"
} # })
I put that same coding behind a button on a GUI. It seems to work initially, the GUI comes up,
https://i.postimg.cc/xJ3g9CzX/GUI-comes-up.jpg (https://postimg.cc/xJ3g9CzX)
, and on clicking the button it appears initially to start OK, , but on the same computers, the coding always hangs at
"checking winget…"
#
Add-Type -AssemblyName System.Windows.Forms
# Create a new form
$Form = New-Object system.Windows.Forms.Form
# Define the size
$Form.ClientSize = '800, 600'
# Range to put button in
$Panel10 = New-Object system.Windows.Forms.Panel ; $Panel10.height = 50 ; $Panel10.width = 250 ; $Panel10.location = New-Object System.Drawing.Point(1, 25)
# function to create sinple botton
function Create-Button {param([string]$Text, [int]$FntSz, [int]$Width, [int]$Height, [int]$ClmX, [int]$RwY)#As Object ' This function allows us to make a buttons in one line. (Those later single lines do not make the button appear)
$Btn = New-Object System.Windows.Forms.Button #
$Btn.Text = $Text #
$Btn.Width = $Width ; $Btn.Height = $Height #
#
$Btn.Location = New-Object System.Drawing.Point($ClmX, $RwY) #
$Btn.Font = New-Object System.Drawing.Font('Arial', $FntSz) # ('Microsoft Sans Serif', 9)
#
return $Btn } #
# Make button
$GetWinGet = Create-Button -Text "winget" -FntSz 9 -Width 117 -Height 21 -ClmX 3 -RwY 1
$GetWinGet.Add_Click({
Write-Host "Checking winget..." # PROBLEM!!!! This wont work in a button - it freezes here?
if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe){ # Check if winget is installed
'Winget Already Installed'
}
else{
# Installing winget from the Microsoft Store
Write-Host "Winget not found, installing it now."
$ResultText.text = "`r`n" +"`r`n" + "Installing Winget... Please Wait"
Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget" # If I paste that link in Browser URL I get this offered as if I hit the download button somewhere Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbu ndle
$nid = (Get-Process AppInstaller).Id
Wait-Process -Id $nid
Write-Host Winget Installed
$ResultText.text = "`r`n" +"`r`n" + "Winget Installed - Ready for Next Task"
} })
# Add Button to range
$Panel10.controls.AddRange(@($GetWinGet))
# Add ranbge to Form
$Form.controls.AddRange(@($Panel10))
# Display the form
[void]$Form.ShowDialog()
On this same GUI I can put lots of other buttons, all doing different things, and they always do what they should**
What am I missing?
Alan
DocAElstein
02-06-2022, 07:32 PM
Test
#
Add-Type -AssemblyName System.Windows.Forms
# Create a new form
$Form = New-Object system.Windows.Forms.Form
# Define the size, title and background color
$Form.ClientSize = '800, 600'
# Range to put button in
$Panel10 = New-Object system.Windows.Forms.Panel ; $Panel10.height = 50 ; $Panel10.width = 250 ; $Panel10.location = New-Object System.Drawing.Point(1, 25)
# function to create sinple botton
function Create-Button {param([string]$Text, [int]$FntSz, [int]$Width, [int]$Height, [int]$ClmX, [int]$RwY)#As Object ' This function allows us to make a buttons in one line. (Those later single lines do not make the button appear)
$Btn = New-Object System.Windows.Forms.Button #
$Btn.Text = $Text #
$Btn.Width = $Width ; $Btn.Height = $Height #
#
$Btn.Location = New-Object System.Drawing.Point($ClmX, $RwY) #
$Btn.Font = New-Object System.Drawing.Font('Arial', $FntSz) # ('Microsoft Sans Serif', 9)
#
return $Btn } #
# Make button
$GetWinGet = Create-Button -Text "winget" -FntSz 9 -Width 117 -Height 21 -ClmX 3 -RwY 1 # $firefox.width = 212
$GetWinGet.Add_Click({
Write-Host "Checking winget..." # PROBLEM!!!! This wont work in a button - it freezes here?
if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe){ # Check if winget is installed
'Winget Already Installed'
}
else{
# Installing winget from the Microsoft Store
Write-Host "Winget not found, installing it now."
$ResultText.text = "`r`n" +"`r`n" + "Installing Winget... Please Wait"
Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget" # If I paste that link in Browser URL I get this offered as if I hit the download button somewhere Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbu ndle #$vscode.width = 211
$nid = (Get-Process AppInstaller).Id
Wait-Process -Id $nid
Write-Host Winget Installed
$ResultText.text = "`r`n" +"`r`n" + "Winget Installed - Ready for Next Task"
} })
# Add Button to range
$Panel10.controls.AddRange(@($GetWinGet))
# Add ranbge to Form
$Form.controls.AddRange(@($Panel10))
# Display the form
[void]$Form.ShowDialog()
#
Add-Type -AssemblyName System.Windows.Forms
# Create a new form
$Form = New-Object system.Windows.Forms.Form
# Define the size, title and background color
$Form.ClientSize = '800, 600'
# Range to put button in
$Panel10 = New-Object system.Windows.Forms.Panel ; $Panel10.height = 50 ; $Panel10.width = 250 ; $Panel10.location = New-Object System.Drawing.Point(1, 25)
# function to create sinple botton
function Create-Button {param([string]$Text, [int]$FntSz, [int]$Width, [int]$Height, [int]$ClmX, [int]$RwY)#As Object ' This function allows us to make a buttons in one line. (Those later single lines do not make the button appear)
$Btn = New-Object System.Windows.Forms.Button #
$Btn.Text = $Text #
$Btn.Width = $Width ; $Btn.Height = $Height #
#
$Btn.Location = New-Object System.Drawing.Point($ClmX, $RwY) #
$Btn.Font = New-Object System.Drawing.Font('Arial', $FntSz) # ('Microsoft Sans Serif', 9)
#
return $Btn } #
# Make button
$GetWinGet = Create-Button -Text "winget" -FntSz 9 -Width 117 -Height 21 -ClmX 3 -RwY 1 # $firefox.width = 212
$GetWinGet.Add_Click({
Write-Host "Checking winget..." # PROBLEM!!!! This wont work in a button - it freezes here?
if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe){ # Check if winget is installed
'Winget Already Installed'
}
else{
# Installing winget from the Microsoft Store
Write-Host "Winget not found, installing it now."
$ResultText.text = "`r`n" +"`r`n" + "Installing Winget... Please Wait"
Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget" # If I paste that link in Browser URL I get this offered as if I hit the download button somewhere Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbu ndle #$vscode.width = 211
$nid = (Get-Process AppInstaller).Id
Wait-Process -Id $nid
Write-Host Winget Installed
$ResultText.text = "`r`n" +"`r`n" + "Winget Installed - Ready for Next Task"
} })
# Add Button to range
$Panel10.controls.AddRange(@($GetWinGet))
# Add ranbge to Form
$Form.controls.AddRange(@($Panel10))
# Display the form
[void]$Form.ShowDialog()
DocAElstein
02-08-2022, 09:29 PM
In support of this forum post
https://excelfox.com/forum/showthread.php/2783-User-Form-entry-in-a-second-sheet-need-help-with-VBA-code?p=16373&viewfull=1#post16373
_____ Workbook: Work_file.xlsm ( Using Excel 2007 32 bit )
Row\ColABCDEFGHI
1S.No.YearMonthNameProjectTaskAmountSubmitted By
2
1
2022JanuarybbbProject2Task2
100Liviu Popescu
3
2
2022FebruarycccProject5Task1
200Liviu Popescu
4
3
2022MarchaaaProject3Task2
500Liviu Popescu
5
Worksheet: Database
_____ Workbook: Work_file.xlsm ( Using Excel 2007 32 bit )
Row\ColABCDEFG
1NameProjectTask
01-22
02-22
03-22
04-22
2aaaProject1Task1
3aaaProject1Task2
4aaaProject2Task1
5aaaProject2Task2
6aaaProject3Task1
7aaaProject3Task2
8aaaProject4Task1
9aaaProject4Task2
10aaaProject5Task1
11aaaProject5Task2
12bbbProject1Task1
13bbbProject1Task2
14bbbProject2Task1
15bbbProject2Task2
16bbbProject3Task1
17bbbProject3Task2
18bbbProject4Task1
19bbbProject4Task2
20bbbProject5Task1
21bbbProject5Task2
22cccProject1Task1
23cccProject1Task2
24cccProject2Task1
25cccProject2Task2
26cccProject3Task1
27cccProject3Task2
28cccProject4Task1
29cccProject4Task2
30cccProject5Task1
31cccProject5Task2
32dddProject1Task1
33dddProject1Task2
Worksheet: Database1
DocAElstein
02-08-2022, 09:29 PM
In support of this forum post
https://excelfox.com/forum/showthread.php/2783-User-Form-entry-in-a-second-sheet-need-help-with-VBA-code?p=16376&viewfull=1#post16376
Before, as we had before
_____ Workbook: Work_file.xlsm ( Using Excel 2007 32 bit )
Row\ColABCDEFGHI
1S.No.YearMonthNameProjectTaskAmountSubmitted By
2
1
2022JanuarybbbProject2Task2
100Liviu Popescu
3
2
2022FebruarycccProject5Task1
200Liviu Popescu
4
3
2022MarchaaaProject3Task2
500Liviu Popescu
5
Worksheet: Database
_____ Workbook: Work_file.xlsm ( Using Excel 2007 32 bit )
Row\ColABCDEFG
1NameProjectTask
01-22
02-22
03-22
04-22
2aaaProject1Task1
3aaaProject1Task2
4aaaProject2Task1
5aaaProject2Task2
6aaaProject3Task1
7aaaProject3Task2
8aaaProject4Task1
9aaaProject4Task2
10aaaProject5Task1
11aaaProject5Task2
12bbbProject1Task1
13bbbProject1Task2
14bbbProject2Task1
15bbbProject2Task2
16bbbProject3Task1
17bbbProject3Task2
18bbbProject4Task1
19bbbProject4Task2
20bbbProject5Task1
21bbbProject5Task2
22cccProject1Task1
23cccProject1Task2
24cccProject2Task1
25cccProject2Task2
26cccProject3Task1
27cccProject3Task2
28cccProject4Task1
29cccProject4Task2
30cccProject5Task1
31cccProject5Task2
32dddProject1Task1
33dddProject1Task2
Worksheet: Database1
DocAElstein
02-08-2022, 09:29 PM
In support of this forum post
https://excelfox.com/forum/showthread.php/2783-User-Form-entry-in-a-second-sheet-need-help-with-VBA-code?p=16376&viewfull=1#post16376
After
_____ Workbook: Work_file.xlsm ( Using Excel 2007 32 bit )
Row\Col
A
B
C
D
E
F
G
1NameProjectTask
01-22
02-22
03-22
04-22
2aaaProject1Task1
3aaaProject1Task2
4aaaProject2Task1
5aaaProject2Task2
6aaaProject3Task1
7aaaProject3Task2
500
8aaaProject4Task1
9aaaProject4Task2
10aaaProject5Task1
11aaaProject5Task2
12bbbProject1Task1
13bbbProject1Task2
14bbbProject2Task1
15bbbProject2Task2
100
16bbbProject3Task1
17bbbProject3Task2
18bbbProject4Task1
19bbbProject4Task2
20bbbProject5Task1
21bbbProject5Task2
22cccProject1Task1
23cccProject1Task2
24cccProject2Task1
25cccProject2Task2
26cccProject3Task1
27cccProject3Task2
28cccProject4Task1
29cccProject4Task2
30cccProject5Task1
200
31cccProject5Task2
32dddProject1Task1
Worksheet: Database1
DocAElstein
02-08-2022, 09:29 PM
In support of this forum post
https://excelfox.com/forum/showthread.php/2783-User-Form-entry-in-a-second-sheet-need-help-with-VBA-code?p=16376&viewfull=1#post16376
After
_____ Workbook: Work_file.xlsm ( Using Excel 2007 32 bit )
Row\Col
A
B
C
D
E
F
G
1NameProjectTask
01-22
02-22
03-22
04-22
2aaaProject1Task1
3aaaProject1Task2
4aaaProject2Task1
5aaaProject2Task2
6aaaProject3Task1
7aaaProject3Task2
500
8aaaProject4Task1
9aaaProject4Task2
10aaaProject5Task1
11aaaProject5Task2
12bbbProject1Task1
13bbbProject1Task2
14bbbProject2Task1
15bbbProject2Task2
100
16bbbProject3Task1
17bbbProject3Task2
18bbbProject4Task1
19bbbProject4Task2
20bbbProject5Task1
21bbbProject5Task2
22cccProject1Task1
23cccProject1Task2
24cccProject2Task1
25cccProject2Task2
26cccProject3Task1
27cccProject3Task2
28cccProject4Task1
29cccProject4Task2
30cccProject5Task1
200
31cccProject5Task2
32dddProject1Task1
Worksheet: Database1
DocAElstein
02-09-2022, 07:58 PM
In support of these forum posts
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
https://eileenslounge.com/viewtopic.php?f=18&t=37740
https://eileenslounge.com/viewtopic.php?f=18&t=37712
https://eileenslounge.com/viewtopic.php?f=18&t=37707
'Version : 5.1.19041.1320
'InstanceId : e165cf30-9ddd-49ed-96c7-59cca98516ee
'UI: System.Management.Automation.Internal.Host.Interna lHostUserInterface
'CurrentCulture: DE -DE
'CurrentUICulture: DE -DE
'PrivateData: Microsoft.PowerShell.Host.ISE.ISEOptions
'DebuggerEnabled : True
'IsRunspacePushed : False
'Runspace: System.Management.Automation.Runspaces.LocalRunspa ce
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707
Sub Services() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 1000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)
' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)
' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, -1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, -1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If
Next Cnt
' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit
End Sub
Edit Some issues…
I messed up with a few things.
_ the display name could be long and go up to the startuptype in the text file, which messed up the manipulation of a line of data from the text file a bit. For now I fiddled that by adding some spaces before the words used for the startuptype. A better solution will probably wait until I fully understand the PowerShell code line
_ There seems to be some strange effects with something somewhere working too slow, too fast or not giving accurate information about if a text file is present. For now that is fiddled with some Waits , Dirs and a Kill. That will do for now, but that need to be looked at again when I understand better wots going on
The next code version is in the next post
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16369&viewfull=1#post16369
DocAElstein
02-09-2022, 07:58 PM
In support of these forum posts
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
https://eileenslounge.com/viewtopic.php?f=18&t=37740
https://eileenslounge.com/viewtopic.php?f=18&t=37712
https://eileenslounge.com/viewtopic.php?f=18&t=37707
'Version : 5.1.19041.1320
'InstanceId : e165cf30-9ddd-49ed-96c7-59cca98516ee
'UI: System.Management.Automation.Internal.Host.Interna lHostUserInterface
'CurrentCulture: DE -DE
'CurrentUICulture: DE -DE
'PrivateData: Microsoft.PowerShell.Host.ISE.ISEOptions
'DebuggerEnabled : True
'IsRunspacePushed : False
'Runspace: System.Management.Automation.Runspaces.LocalRunspa ce
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707
Sub Services() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 1000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)
' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)
' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, -1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, -1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If
Next Cnt
' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit
End Sub
Edit Some issues…
I messed up with a few things.
_ the display name could be long and go up to the startuptype in the text file, which messed up the manipulation of a line of data from the text file a bit. For now I fiddled that by adding some spaces before the words used for the startuptype. A better solution will probably wait until I fully understand the PowerShell code line
_ There seems to be some strange effects with something somewhere working too slow, too fast or not giving accurate information about if a text file is present. For now that is fiddled with some Waits , Dirs and a Kill. That will do for now, but that need to be looked at again when I understand better wots going on
The next code version is in the next post
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16369&viewfull=1#post16369
DocAElstein
02-09-2022, 11:45 PM
Macro for this post
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'In support of these forum posts
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707
Sub Services2() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' kill the text file before I make it, because the code might otherwise use a previous one, as it takes a second or so to overwrite the old or make a new one
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> ""
If Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> "" Then Kill PathName:="" & ThisWorkbook.Path & Application.PathSeparator & "test.txt"
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents
' Application.Wait (Now + TimeValue("0:00:01")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have???
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 2000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' we need to wait a bit until the text file is made
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) = ""
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents ' I chucked this in, but did not really have any reason
Application.Wait (Now + TimeValue("0:00:02")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have??? 01 seemed OK - I made it 2
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)
' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)
' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' This is a bit of a temporary bodge as the Display name sometimes pushes up to the startuptype which screws up the string manipulation below
Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Manual", " Manual", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Automatic", " Auotomatic", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Disabled", " Disabled", 1, 1, vbBinaryCompare)
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, 1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, 1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If
Next Cnt
' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit
End Sub
DocAElstein
02-09-2022, 11:45 PM
test
https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls
try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls
try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls
try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls
try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs
DocAElstein
02-09-2022, 11:45 PM
test
https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls
try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls
try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls
try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls
try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs
DocAElstein
02-09-2022, 11:45 PM
Macro for this post
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'In support of these forum posts
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707
Sub Services2() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' kill the text file before I make it, because the code might otherwise use a previous one, as it takes a second or so to overwrite the old or make a new one
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> ""
If Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> "" Then Kill PathName:="" & ThisWorkbook.Path & Application.PathSeparator & "test.txt"
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents
' Application.Wait (Now + TimeValue("0:00:01")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have???
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 2000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' we need to wait a bit until the text file is made
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) = ""
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents ' I chucked this in, but did not really have any reason
Application.Wait (Now + TimeValue("0:00:02")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have??? 01 seemed OK - I made it 2
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)
' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)
' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' This is a bit of a temporary bodge as the Display name sometimes pushes up to the startuptype which screws up the string manipulation below
Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Manual", " Manual", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Automatic", " Auotomatic", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Disabled", " Disabled", 1, 1, vbBinaryCompare)
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, 1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, 1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If
Next Cnt
' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit
End Sub
DocAElstein
02-09-2022, 11:45 PM
test
https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls
try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls
try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls
try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls
try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs
DocAElstein
02-09-2022, 11:45 PM
test
https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls
try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls
try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls
try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls
try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs
DocAElstein
02-09-2022, 11:45 PM
<div class="gmail_chip gmail_drive_chip">
<div class="gmail_chip gmail_drive_chip">
<p style="margin: 0px;"><span style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000; text-decoration: none;"><a href="https://www.youtube.com/watch?v=5ckOWXGDL34&lc=UgyqZfLMydnVuNbtqTR4AaABAg. 9ZBy1PrRmM89ZEE6b4w03-">https://www.youtube.com/watch?v=5ckOWXGDL34&lc=UgyqZfLMydnVuNbtqTR4AaABAg. 9ZBy1PrRmM89ZEE6b4w03-</a> 7<br /></span></p>
<p style="margin: 0px;"><span style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000; text-decoration: none;">https://www.youtube.com/watch?v=5ckOWXGDL34&lc=UgzW4-G9Rh2o5ljabrV4AaABAg</span> 13 </p>
</div>
DocAElstein
02-09-2022, 11:45 PM
In support of this post https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12782
Security tweaks
# Will like XP or Win7 Disable Windows Defender Disable Defender Updates Set UAC to Never Prompt Disable Meltdown Flag Disable Windows Malware Scan
$securitylow.Add_Click({
Write-Host "Lowering UAC level..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "ConsentPromptBehaviorAdmin" -Type DWord -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "PromptOnSecureDesktop" -Type DWord -Value 0
Write-Host "Disabling Windows Defender..."
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Force | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -Type DWord -Value 1
If ([System.Environment]::OSVersion.Version.Build -eq 14393) {
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "WindowsDefender" -ErrorAction SilentlyContinue
} ElseIf ([System.Environment]::OSVersion.Version.Build -ge 15063) {
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "SecurityHealth" -ErrorAction SilentlyContinue
}
Write-Host "Disabling Windows Defender Cloud..."
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Force | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SpynetReporting" -Type DWord -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -Type DWord -Value 2
Write-Host "Disabling Meltdown (CVE-2017-5754) compatibility flag..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat" -Name "cadca5fe-87d3-4b96-b7fb-a231484277cc" -ErrorAction SilentlyContinue
Write-Host "Disabling Malicious Software Removal Tool offering..."
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" -Name "DontOfferThroughWUAU" -Type DWord -Value 1
$wshell.Popup("Operation Completed",0,"Done",0x0)
})
# Enable Windows Malware Scan Enable Meltdown Flag Disable Windows Defender Set UAC to Always Prompt Disable Defender Updates
$securityhigh.Add_Click({
Write-Host "Raising UAC level..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "ConsentPromptBehaviorAdmin" -Type DWord -Value 5
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "PromptOnSecureDesktop" -Type DWord -Value 1
Write-Host "Disabling SMB 1.0 protocol..."
Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force
Write-Host "Enabling Windows Defender..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -ErrorAction SilentlyContinue
If ([System.Environment]::OSVersion.Version.Build -eq 14393) {
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "WindowsDefender" -Type ExpandString -Value "`"%ProgramFiles%\Windows Defender\MSASCuiL.exe`""
} ElseIf ([System.Environment]::OSVersion.Version.Build -ge 15063) {
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "SecurityHealth" -Type ExpandString -Value "`"%ProgramFiles%\Windows Defender\MSASCuiL.exe`""
}
Write-Host "Enabling Windows Defender Cloud..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SpynetReporting" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -ErrorAction SilentlyContinue
Write-Host "Disabling Windows Script Host..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name "Enabled" -Type DWord -Value 0
Write-Host "Enabling Meltdown (CVE-2017-5754) compatibility flag..."
If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat")) {
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat" | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat" -Name "cadca5fe-87d3-4b96-b7fb-a231484277cc" -Type DWord -Value 0
Write-Host "Enabling Malicious Software Removal Tool offering..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" -Name "DontOfferThroughWUAU" -ErrorAction SilentlyContinue
$wshell.Popup("Operation Completed",0,"Done",0x0)
})
DocAElstein
02-09-2022, 11:45 PM
In support of this post
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12783
The ps1 file, and also below the $WindowsSearch.Add_Click(
Share ‘ChrisSearchTweaks18-19July.ps1 https://app.box.com/s/cbs7go8i2tdxw4wguthgxcviecaxjn6b
iex ((New-Object System.Net.WebClient).DownloadString(' https://raw.githubusercontent.com/ChrisTitusTech/win10script/71609526b132f5cd7e3b9167779af60051a80912/win10debloat.ps1'))
$windowssearch.Add_Click({
Write-Host "Disabling Bing Search in Start Menu..."
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Se arch" -Name "BingSearchEnabled" -Type DWord -Value 0
<#
Write-Host "Disabling Cortana"
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Se arch" -Name "CortanaConsent" -Type DWord -Value 0
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Force | Out-Null
}
#>
Write-Host "Hiding Search Box / Button..."
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Se arch" -Name "SearchboxTaskbarMode" -Type DWord -Value 0
Write-Host "Removing Start Menu Tiles"
Set-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -Value '<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <LayoutOptions StartTileGroupCellWidth="6" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <DefaultLayoutOverride>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <StartLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <defaultlayout:StartLayout GroupCellWidth="6" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </StartLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </DefaultLayoutOverride>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <CustomTaskbarLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <defaultlayout:TaskbarLayout>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:TaskbarPinList>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:UWA AppUserModelID="Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdg e" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:DesktopApp DesktopApplicationLinkPath="%APPDATA%\Microsoft\Windows\Start Menu\Programs\System Tools\File Explorer.lnk" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </taskbar:TaskbarPinList>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </defaultlayout:TaskbarLayout>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </CustomTaskbarLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value '</LayoutModificationTemplate>'
$START_MENU_LAYOUT = @"
<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns:taskbar="http://schemas.microsoft.com/Start/2014/TaskbarLayout" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
<LayoutOptions StartTileGroupCellWidth="6" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6" />
</StartLayoutCollection>
</DefaultLayoutOverride>
</LayoutModificationTemplate>
"@
$layoutFile="C:\Windows\StartMenuLayout.xml"
#Delete layout file if it already exists
If(Test-Path $layoutFile)
{
Remove-Item $layoutFile
}
#Creates the blank layout file
$START_MENU_LAYOUT | Out-File $layoutFile -Encoding ASCII
$regAliases = @("HKLM", "HKCU")
#Assign the start layout and force it to apply with "LockedStartLayout" at both the machine and user level
foreach ($regAlias in $regAliases){
$basePath = $regAlias + ":\SOFTWARE\Policies\Microsoft\Windows"
$keyPath = $basePath + "\Explorer"
IF(!(Test-Path -Path $keyPath)) {
New-Item -Path $basePath -Name "Explorer"
}
Set-ItemProperty -Path $keyPath -Name "LockedStartLayout" -Value 1
Set-ItemProperty -Path $keyPath -Name "StartLayoutFile" -Value $layoutFile
}
#Restart Explorer, open the start menu (necessary to load the new layout), and give it a few seconds to process
Stop-Process -name explorer
Start-Sleep -s 5
$wshell = New-Object -ComObject wscript.shell; $wshell.SendKeys('^{ESCAPE}')
Start-Sleep -s 5
#Enable the ability to pin items again by disabling "LockedStartLayout"
foreach ($regAlias in $regAliases){
$basePath = $regAlias + ":\SOFTWARE\Policies\Microsoft\Windows"
$keyPath = $basePath + "\Explorer"
Set-ItemProperty -Path $keyPath -Name "LockedStartLayout" -Value 0
Write-Host "Search and Start Menu Tweaks Complete"
} # This was missing 12 July 2021
})
DocAElstein
02-09-2022, 11:45 PM
jADHKJASHDKJahdjkAHD
DocAElstein
02-09-2022, 11:45 PM
<div class="gmail_chip gmail_drive_chip"> </div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/1UFQySI4QjTTV0O5xnLnLfx5iJh_qDzct/view?usp=drive_web" target="_blank" rel="noopener" aria-label="5.50 8.18 Clean Up Windows 10 _ 3 Steps For A Faster Computer-mWHiP9K8fQ0_16 10 2019.wmv"><img src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" alt="" data-upload="true" /> <span dir="ltr">5.50 8.18 Clean Up Windows 10 _ 3 Steps For A ...</span></a><img src="res/6c654bc40d912309e7cc090257628b4f/texteditor/void.gif" alt="" data-upload="true" /></div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/11mjTzHbcdY1EwVaV0-AIAmYgC2DCsp7X/view?usp=drive_web" target="_blank" rel="noopener" aria-label="7.56 8 (Ransome) How to Make Windows 10 Secure-pGcerfVqYyU_31 01 2020.wmv"><img src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" alt="" data-upload="true" /> <span dir="ltr">7.56 8 (Ransome) How to Make Windows 10 Secur...</span></a><img src="res/6c654bc40d912309e7cc090257628b4f/texteditor/void.gif" alt="" data-upload="true" /></div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/1b_akgpleMvL4lD4qXYffzUEXh8WhUyZ7/view?usp=drive_web" target="_blank" rel="noopener" aria-label="8.45 Speed Up Windows 10 in 2020-8E6OT_QcHaU_20 06 2020.wmv"><img src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" alt="" data-upload="true" /> <span dir="ltr">8.45 Speed Up Windows 10 in 2020-8E6OT_QcHaU_20...</span></a><img src="res/6c654bc40d912309e7cc090257628b4f/texteditor/void.gif" alt="" data-upload="true" /></div>
<div class="gmail_chip gmail_drive_chip"> </div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/1O63RdRCQS2OvWa50F56m6KyryVsBImIK/view?usp=drive_web" target="_blank" rel="noopener" aria-label="8.94 Creating New Windows 10 Debloat Scripts fo..."><img src="https://drive-thirdparty.googleusercontent.com/16/type/video/x-ms-wmv" alt="" data-upload="true" /> <span dir="ltr">8.94 Creating New Windows 10 Debloat Scripts fo...</span></a></div>
<div class="gmail_chip gmail_drive_chip"> </div>
DocAElstein
02-09-2022, 11:45 PM
khskjhkshhhfhfhfslhafhalfh
DocAElstein
03-28-2022, 04:13 PM
In support of these issues
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12784 https://www.youtube.com/watch?v=dKM8ZScbic8&t=75s
Winget issues https://github.com/ChrisTitusTech/win10script/commit/f2774eac480a71e710f90763ea770ae56d3b6e85
https://github.com/ChrisTitusTech/win10script/commit/9c0cc78e2a15aed3d42fa1a0b3b236f3ecf290db
06.07.2021 The Best Windows Utility ( second nice shade of grey GUI )
Write-Host "Checking winget..."
Try{
# Check if winget is already installed
$er = (invoke-expression "winget -v") 2>&1
if ($lastexitcode) {throw $er}
Write-Host "winget is already installed."
}
Catch{
# winget is not installed. Install it from the Github release
Write-Host "winget is not found, installing it right now."
$download = "https://github.com/microsoft/winget-cli/releases/download/v1.0.11692/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbu ndle"
$output = $PSScriptRoot + "\winget-latest.appxbundle"
Write-Host "Dowloading latest release"
Invoke-WebRequest -Uri $download -OutFile $output
Write-Host "Installing the package"
Add-AppxPackage -Path $output
}
Finally {
# Start installing the packages with winget
#Get-Content .\winget.txt | ForEach-Object {
# iex ("winget install -e " + $_)
#}
}
The Ultimate Windows Utility Upgrade 29 09 2021
Write-Host "Checking winget..."
Try{
# Check if winget is already installed
$er = (invoke-expression "winget -v") 2>&1
if ($lastexitcode) {throw $er}
Write-Host "winget is already installed."
}
Catch{
# winget is not installed. Install it from the Microsoft Store
Write-Host "winget is not found, installing it right now."
Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
$nid = (Get-Process AppInstaller).id
Wait-Process -Id $nid
}
Finally {
# Start installing the packages with winget
#Get-Content .\winget.txt | ForEach-Object {
# iex ("winget install -e " + $_)
#}
}
A commit a bit later by mrhaydendp to simplify a bit https://github.com/ChrisTitusTech/win10script/commit/9c0cc78e2a15aed3d42fa1a0b3b236f3ecf290db?diff=spli t
Write-Host "Checking winget..."
# Check if winget is installed
if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe){
'Winget Already Installed'
}
else{
# Installing winget from the Microsoft Store
Write-Host "Winget not found, installing it now."
Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
$nid = (Get-Process AppInstaller).Id
Wait-Process -Id $nid
Write-Host Winget Installed
}
DocAElstein
04-16-2022, 10:23 PM
Test
17-121-114-118.applebot.apple.com
header1header2A Header Last Column Header
0SubItemSubItemSubItemSubItem<-- This is a ListView Item. It has an Item number of 0 and an Item idenitfier/name of 345
1SubItemSubItemSubItemSubItem<-- This is a ListView Item. It has an Item number of 1 and an Item idenitfier/name of 232
2SubItemSubItemSubItemSubItem<-- This is a ListView Item. It has an Item number of 2 and an Item idenitfier/name of 36
header1header2A Header Last Column Header
0SubItemSubItemSubItem<-- This brown thing is a ListView Item. It has an Item number of 0 and an Item idenitfier/name of 345
1SubItemSubItemSubItem<-- This blue thing is a ListView Item. It has an Item number of 1 and an Item idenitfier/name of 232
2SubItemSubItemSubItem<-- This purple thing is a ListView Item. It has an Item number of 2 and an Item idenitfier/name of 36
[size=0]
header1header2A Header Last Header<-- This bit with the created “column” is part of the main ListView object
0\ 345 SubItemSubItemSubItem<-- This brown thing is a ListViewItem object. It has an Item number of 0,
and an Item identifier/name of 345
1\ 232 SubItemSubItemSubItem<-- This blue thing is a ListViewItem object. It has an Item number of 1,
and an Item identifier/name of 232
2\ 36 SubItemSubItemSubItem<-- This purple thing is a ListViewItem object. It has an Item number of 2
and an Item identifier/name of 36
__
In the above schematic we are showing 4 objects. The last three belong to the first one, ( after they have been ned to it ).
The values in the first column somehow belong to the main ListView object.
SubItems are Added to the ListViewItems
DocAElstein
04-26-2022, 12:19 PM
In support of this Thread https://eileenslounge.com/viewtopic.php?f=30&t=38110
https://eileenslounge.com/viewtopic.php?p=294721#p294721
Vertical to Horizontal,
This https://i.postimg.cc/14t4nPfD/This-Virtical.jpg (https://postimg.cc/14t4nPfD) to this https://i.postimg.cc/ygfdQprJ/That-Horizintal.jpg (https://postimg.cc/ygfdQprJ)
Part 1 The main data Vertical to Horizontal
An idea I have is to build up the single string that we know can be put into the Windows Clipboard, and then pasted out into Excel. ( http://www.eileenslounge.com/viewtopic.php?p=242941#p242941 )
I basically build that up with some Do While Loopy stuff
The Full Story
The usual worksheets defining and data getting information stuff.
( We capture one extra empty row, because, past experience with these sort of Do While Loopy stuff has shown that it can help simplify some conditional comparison things and/ or help prevent arrays doing out of bounds by one row.
Rem 1
The purpose of this is to get that maximum Amounts or Notes count, ( the biggest group ) ( which is 4 in the given example )
But its worth looking at how that works since the basic Do While Loop is then used in the next main ( Rem 2 ) section.
The #### Main Outer Loop keeps us going through all data rows
Within that the ' ---- Inner Loop that takes us through a group
This loop adds the things in the group, and after each loop is finished we check If the count was the biggest group so far.
Rem 2
This is the main meat of the solution.
First, exactly as before we have a #### Main Outer Loop keeps us going through all data rows
Within that Main Outer Loop we now have 2 inner loops.
'2a
The '2a The first inner loop one does something similar to before. It loops for a group. This time within it we build up two strings that we need for a line in the output.
As example, for the first group we are basically trying to build up these two strings, ( Just before we start that loop, we tack onto the string at the start the group name, which is A in the first group example.
This is what we would see, for example in the immediate window, for querying the string content after, in this example, the the loops for that inner loop
? strClipL
A vbTab 10 vbTab 20 vbTab 30
? strClipR
vbTab N1 vbTab N2 vbTab N3
( For the sake of clarity I use a vbTab to indicate the “invisible” vbTab characters, which is actually on those strings )
'2b
The purpose of '2b the second inner loop is to ,( if necessary ), give us effectively extra empty cells, ( achieved by adding a vbTab of the strings.
Using the same example, we would see that the loop is needed to be done once, and at the end of that single loop, our strings are modifies such:
? strClipL
A vbTab 10 vbTab 20 vbTab 30 vbTab
? strClipR
vbTab N1 vbTab N2 vbTab N3 vbTab
'2c
At this point we combine the two strings and add a line separator so that this row data can be added onto by the next row data
So as to be sure what I have and demonstrate it more clearly, I added a line in testing which calls a function of mine , ( https://excelfox.com/forum/showthread.php/2302-quot-What%e2%80%99s-in-a-String-quot-VBA-break-down-Loop-through-character-contents-of-a-string?p=15522&viewfull=1#post15522 ) , which checks that line screen,
Here is the result
"A" & vbTab & "10" & vbTab & "20" & vbTab & "30" & vbTab & vbTab & "N1" & vbTab & "N2" & vbTab & "N3" & vbTab & vbTab & "GroupA" & vbCr & vbLf
That looks about correct.
Doing a few other tests, suggest to me that I have the final result that I need: https://i.postimg.cc/xcbJDZgM/StrClip.jpg (https://postimg.cc/xcbJDZgM)
? strclip
A 10 20 30 N1 N2 N3 GroupA
B 40 50 60 70 N4 N5 N6 N7 GroupB
C 80 N8 GroupC
D 90 100 N9 N10 GroupD
"A" & vbTab & "10" & vbTab & "20" & vbTab & "30" & vbTab & vbTab & "N1" & vbTab & "N2" & vbTab & "N3" & vbTab & vbTab & "GroupA" & vbCr & vbLf & "B" & vbTab & "40" & vbTab & "50" & vbTab & "60" & vbTab & "70" & vbTab & "N4" & vbTab & "N5" & vbTab & "N6" & vbTab & "N7" & vbTab & "GroupB" & vbCr & vbLf & "C" & vbTab & "80" & vbTab & vbTab & vbTab & vbTab & "N8" & vbTab & vbTab & vbTab & vbTab & "GroupC" & vbCr & vbLf & "D" & vbTab & "90" & vbTab & "100" & vbTab & vbTab & vbTab & "N9" & vbTab & "N10" & vbTab & vbTab & vbTab & "GroupD" & vbCr & vbLf
' Ref
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31395#p242941
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31489#p243731
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31938#p247681
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31849&start=20#p246887
https://eileenslounge.com/viewtopic.php?p=294721#p294721
' http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
' https://stackoverflow.com/questions/25091571/strange-behavior-from-vba-dataobject-gettext-returns-what-is-currently-on-the-c/54960767#54960767
' https://stackoverflow.com/questions/31439866/multiple-variable-arguments-to-application-ontime/59812342#59812342
‘ http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
‘ https://www.myonlinetraininghub.com/excel-clipboard https://support.microsoft.com/en-us/office/copy-and-paste-using-the-office-clipboard-714a72af-1ad4-450f-8708-c2931e73ec8a?ui=en-us&rs=en-us&ad=us&fromar=1#bm2b
‘ https://www.thespreadsheetguru.com/blog/2014/2/20/how-to-create-a-personal-macro-file
‘ https://excelribbon.tips.net/T009810_Cant_Empty_the_Clipboard.html
‘ https://www.excelforum.com/excel-programming-vba-macros/1288935-copy-to-clipboard-not-working.html
‘ https://www.thespreadsheetguru.com/blog/2015/1/13/how-to-use-vba-code-to-copy-text-to-the-clipboard
https://excelribbon.tips.net/T010691_Message_about_a_Problem_with_the_Clipboard .html
https://excel.tips.net/T003111_Cant_Copy_Data_between_Workbooks.html
' VBA to clear the Office Clipboard http://www.eileenslounge.com/viewtopic.php?p=246838&sid=e1b0b87e47d419c09c526558cc634c64#p246838
DocAElstein
04-26-2022, 06:16 PM
Coding so far , for last post, https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16529&viewfull=1#post16529
' https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16529&viewfull=1#post16529
' http://www.eileenslounge.com/viewtopic.php?f=30&t=38110&p=294692#p294692
Sub Stantial()
Rem 0 data
Dim Ws1 As Worksheet: Set Ws1 = ThisWorkbook.Worksheets("Sheet1")
Dim RngPlus1 As Range
Set RngPlus1 = Ws1.Cells.Item(1).CurrentRegion.Resize(Ws1.Cells.I tem(1).CurrentRegion.Rows.Count + 1, Ws1.Cells.Item(1).CurrentRegion.Columns.Count)
Dim vArr() As Variant: Let vArr() = RngPlus1.Value2
Rem 1 determine the biggest group ( that maximum Amounts or Notes count )
Dim Cnt As Long, Cnt2 As Long, Mx As Long: Let Mx = 1: Let Cnt = 1
Do ' ############################# Main Outer Loop keeps us going through all data rows
Do ' ----------------- Inner Loop that takes us through a group
Let Cnt = Cnt + 1 ' Cnt is the main data row number
Let Cnt2 = Cnt2 + 1
Loop While vArr(Cnt + 1, 1) = vArr(Cnt, 1) ' ---- Inner Loop that takes us through a group
If Cnt2 > Mx Then Let Mx = Cnt2
Let Cnt2 = 0
Loop While Cnt < UBound(vArr(), 1) - 1 ' #### Main Outer Loop keeps us going through all data rows
Rem 2 ' ############################# Main Outer Loop keeps us going through all data rows
Let Cnt = 1
Do
Dim HrCnt As Long: Let HrCnt = 1
Dim strClipR As String, strClipL As String: Let strClipL = strClipL & vArr(Cnt + 1, 1)
Do '2a The first inner loop
Let Cnt = Cnt + 1
Let HrCnt = HrCnt + 1
Let strClipL = strClipL & vbTab & vArr(Cnt, 2)
Let strClipR = strClipR & vbTab & vArr(Cnt, 3)
Loop While vArr(Cnt + 1, 1) = vArr(Cnt, 1) ' The first inner loop
Do While HrCnt < Mx + 1 '2b the second inner loop
Let strClipL = strClipL & vbTab
Let strClipR = strClipR & vbTab
Let HrCnt = HrCnt + 1
Loop ' the second inner loop
'2c Finishing off the strings, and final string for an output line, after the inner loops
Let strClipR = strClipR & vbTab & vArr(Cnt, 4) ' add the group name
Dim strClip As String: Let strClip = strClip & strClipL & strClipR & vbCr & vbLf ' join the strings and add a line seperator to the output row string
'Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(strClip)
Let strClipL = "": strClipR = ""
Loop While Cnt < UBound(vArr(), 1) - 1 ' #### Main Outer Loop keeps us going through all data rows
'Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(strClip)
'2d paste strClip out via the windows Clipboard
Dim objDataObject As Object: Set objDataObject = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") ' http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
objDataObject.SetText Text:=strClip
objDataObject.PutInClipboard
Ws1.Paste Destination:=Ws1.Range("G2")
End Sub
DocAElstein
04-26-2022, 06:18 PM
Spare post for later
DocAElstein
04-26-2022, 06:40 PM
Following on from posts,
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16530&viewfull=1#post16530 https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16529&viewfull=1#post16529
http://www.eileenslounge.com/viewtopic.php?p=294692#p294692
,
The header row,
Group Amount1 Amount2 Amount3 Amount4 Notes1 Notes2 Notes3 Notes4 Name
, we could make partially dynamic, as is needed, since we don’t know the maximum number of amounts ( = maximum number of Notes ) , before seeing the data.
We do have the information needed, since Mx contains, in our current example, the required value of 4
Evaluate Range techniques are a convenient way to get these sort of things.
We start by considering spreadsheet formulas such as this,
={"Amount" & COLUMN(A1:D1)}
, which returns us an array, which applied across a range , would give us like
Amount1 Amount2 Amount3 Amount4 https://i.postimg.cc/vxWK4VnG/Amounts-Via-Spreadsheet-Array-Formula.jpg (https://postimg.cc/vxWK4VnG)
Taking that general idea and a few other steps we can finally get at our heading like in this demo coding
' https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16532&viewfull=1#post16532
Sub MakeHeadings()
Dim Mx As Long: Let Mx = 4
Dim Amounts() As Variant
Let Amounts() = Evaluate("=""Amount"" & COLUMN(A1:D1)")
Let Amounts() = Evaluate("=""Amount"" & COLUMN(A:D)")
Let Amounts() = Evaluate("=""Amount"" & COLUMN(A:" & "D" & ")")
' We need to get D from what we know, Mx
Dim vTemp As Variant
vTemp = Cells(1, 4).Address
vTemp = Split(vTemp, "$", 3, vbBinaryCompare)
vTemp = vTemp(1)
' Or
vTemp = Split(Cells(1, 4).Address, "$", 3, vbBinaryCompare)(1)
' Or
vTemp = Split(Cells(1, 4).Address, "$")(1)
vTemp = Split(Cells(1, Mx).Address, "$")(1)
Let Amounts() = Evaluate("=""Amount"" & COLUMN(A:" & vTemp & ")")
Let Amounts() = Evaluate("=""Amount"" & COLUMN(A:" & Split(Cells(1, Mx).Address, "$")(1) & ")")
'
' We want this array as a string with vbTabs seperating the array elements
Dim strAmounts As String
Let strAmounts = Join(Amounts(), vbTab)
Let strAmounts = Join(Evaluate("=""Amount"" & COLUMN(A:" & Split(Cells(1, Mx).Address, "$")(1) & ")"), vbTab)
' similarly for the notes
Dim strNotes As String
Let strNotes = Join(Evaluate("=""Note"" & COLUMN(A:" & Split(Cells(1, Mx).Address, "$")(1) & ")"), vbTab)
' To get our final heading string,
Dim strHd As String
Let strHd = "Group" & vbTab & Join(Evaluate("=""Amount"" & COLUMN(A:" & Split(Cells(1, Mx).Address, "$")(1) & ")"), vbTab) & vbTab & Join(Evaluate("=""Note"" & COLUMN(A:" & Split(Cells(1, Mx).Address, "$")(1) & ")"), vbTab) & vbTab & "Notes"
Dim objDataObject As Object: Set objDataObject = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") ' http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
objDataObject.SetText Text:=strHd
objDataObject.PutInClipboard
Dim Ws1 As Worksheet: Set Ws1 = ThisWorkbook.Worksheets("Sheet1")
Ws1.Paste Destination:=Ws1.Range("G1")
End Sub
In the next post , https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16533&viewfull=1#post16533 , is that integrated into the main coding in Rem 3
DocAElstein
04-26-2022, 07:40 PM
Coding for these posts
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16532&viewfull=1#post16532
Sub Stantially()
Rem 0 data
Dim Ws1 As Worksheet: Set Ws1 = ThisWorkbook.Worksheets("Sheet1")
Dim RngPlus1 As Range
Set RngPlus1 = Ws1.Cells.Item(1).CurrentRegion.Resize(Ws1.Cells.I tem(1).CurrentRegion.Rows.Count + 1, Ws1.Cells.Item(1).CurrentRegion.Columns.Count)
Dim vArr() As Variant: Let vArr() = RngPlus1.Value2
Rem 1 determine the biggest group ( that maximum Amounts or Notes count )
Dim Cnt As Long, Cnt2 As Long, Mx As Long: Let Mx = 1: Let Cnt = 1
Do ' ############################# Main Outer Loop keeps us going through all data rows
Do ' ----------------- Inner Loop that takes us through a group
Let Cnt = Cnt + 1 ' Cnt is the main data row number
Let Cnt2 = Cnt2 + 1
Loop While vArr(Cnt + 1, 1) = vArr(Cnt, 1) ' ---- Inner Loop that takes us through a group
If Cnt2 > Mx Then Let Mx = Cnt2
Let Cnt2 = 0
Loop While Cnt < UBound(vArr(), 1) - 1 ' #### Main Outer Loop keeps us going through all data rows
Rem 2 ' ############################# Main Outer Loop keeps us going through all data rows
Let Cnt = 1
Do
Dim HrCnt As Long: Let HrCnt = 1
Dim strClipR As String, strClipL As String: Let strClipL = strClipL & vArr(Cnt + 1, 1)
Do '2a The first inner loop
Let Cnt = Cnt + 1
Let HrCnt = HrCnt + 1
Let strClipL = strClipL & vbTab & vArr(Cnt, 2)
Let strClipR = strClipR & vbTab & vArr(Cnt, 3)
Loop While vArr(Cnt + 1, 1) = vArr(Cnt, 1) ' The first inner loop
Do While HrCnt < Mx + 1 '2b the second inner loop
Let strClipL = strClipL & vbTab
Let strClipR = strClipR & vbTab
Let HrCnt = HrCnt + 1
Loop ' the second inner loop
'2c Finishing off the strings, and final string for an output line, after the inner loops
Let strClipR = strClipR & vbTab & vArr(Cnt, 4) ' add the group name
Dim strClip As String: Let strClip = strClip & strClipL & strClipR & vbCr & vbLf ' join the strings and add a line seperator to the output row string
'Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(strClip)
Let strClipL = "": strClipR = ""
Loop While Cnt < UBound(vArr(), 1) - 1 ' #### Main Outer Loop keeps us going through all data rows
'Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(strClip)
'2d paste strClip out via the windows Clipboard
Dim objDataObject As Object: Set objDataObject = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") ' http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
objDataObject.SetText Text:=strClip
objDataObject.PutInClipboard
Ws1.Paste Destination:=Ws1.Range("G2")
Rem 3 headers
Dim strHd As String
Let strHd = "Group" & vbTab & Join(Evaluate("=""Amount"" & COLUMN(A:" & Split(Cells(1, Mx).Address, "$")(1) & ")"), vbTab) & vbTab & Join(Evaluate("=""Note"" & COLUMN(A:" & Split(Cells(1, Mx).Address, "$")(1) & ")"), vbTab) & vbTab & "Name"
objDataObject.SetText Text:=strHd
objDataObject.PutInClipboard
Ws1.Paste Destination:=Ws1.Range("G1")
End Sub
DocAElstein
06-17-2022, 02:10 AM
Some extra notes for this main forum post:
http://www.eileenslounge.com/viewtopic.php?f=27&t=38331
This is a sample input,
_____ Workbook: Split- Copy.xlsm ( Using Excel 2007 32 bit )
Row\Col
A
B
21,2,3,4t,y,u,m
Worksheet: Sheet2Original
This is what I want out
_____ Workbook: Split- Copy.xlsm ( Using Excel 2007 32 bit )
Row\Col
A
B
2
1t
3
2y
4
3u
5
4m
Worksheet: Sheet2
I want to do this sort of thing,
__ arrOut()= App.Index(arrIn(), Rws(), Clms())
The arrIn() in this case will be all the input data. Conveniently, we can join the two cell values with a comma then split all that by comma to get a single array, {1 2 3 4 t y u m }
Then we need the Rws() like this
1 1
1 1
1 1
1 1
and the Clms() like this
1 5
2 6
3 7
4 8
' https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16639&viewfull=1#post16639
Sub SplitData4()
Dim Ws2 As Worksheet: Set Ws2 = ThisWorkbook.Worksheets.Item("Sheet2")
Dim strDta As String: Let strDta = Ws2.Range("A2").Value & "," & Ws2.Range("B2").Value
Dim arrIn() As String
Let arrIn() = Split(strDta, ",", -1, vbBinaryCompare)
' Or
arrIn() = Split(Range("A2").Value & "," & Range("B2").Value, ",")
Dim Rws() As Variant
Let Rws() = Evaluate("=Row(1:4)/Row(1:4)*Column(A:B)/Column(A:B)")
Let Rws() = Evaluate("=Row(1:" & (UBound(arrIn()) + 1) / 2 & ")/Row(1:" & (UBound(arrIn()) + 1) / 2 & ")*Column(A:B)/Column(A:B)")
Dim Clms() As Variant
Let Clms() = Evaluate("=Row(1:4)+((Column(A:B)-1)*" & (UBound(arrIn()) + 1) / 2 & ")")
Let Clms() = Evaluate("=Row(1:" & (UBound(arrIn()) + 1) / 2 & ")+((Column(A:B)-1)*" & (UBound(arrIn()) + 1) / 2 & ")")
Dim arrOut() As Variant
Let arrOut() = Application.Index(arrIn(), Rws(), Clms())
Let Ws2.Range("A2").Resize((UBound(arrIn()) + 1) / 2, 2).Value = arrOut()
' Or
' Range("A2").Resize((UBound(arrIn()) + 1) / 2, 2).Value = arrOut()
' Range("A2").Resize((UBound(arrIn()) + 1) / 2, 2).Value = Application.Index(arrIn(), Rws(), Clms())
' Range("A2").Resize((UBound(arrIn()) + 1) / 2, 2).Value = Application.Index(arrIn(), Evaluate("=Row(1:" & (UBound(arrIn()) + 1) / 2 & ")/Row(1:" & (UBound(arrIn()) + 1) / 2 & ")*Column(A:B)/Column(A:B)"), Evaluate("=Row(1:" & (UBound(arrIn()) + 1) / 2 & ")+((Column(A:B)-1)*" & (UBound(arrIn()) + 1) / 2 & ")"))
Range("A2").Resize((UBound(Split(Range("A2").Value & "," & Range("B2").Value, ",")) + 1) / 2, 2).Value = Application.Index(Split(Range("A2").Value & "," & Range("B2").Value, ","), Evaluate("=Row(1:" & (UBound(Split(Range("A2").Value & "," & Range("B2").Value, ",")) + 1) / 2 & ")/Row(1:" & (UBound(Split(Range("A2").Value & "," & Range("B2").Value, ",")) + 1) / 2 & ")*Column(A:B)/Column(A:B)"), Evaluate("=Row(1:" & (UBound(Split(Range("A2").Value & "," & Range("B2").Value, ",")) + 1) / 2 & ")+((Column(A:B)-1)*" & (UBound(Split(Range("A2").Value & "," & Range("B2").Value, ",")) + 1) / 2 & ")"))
End Sub
Sub StantiallyBeautiful() ' http://www.eileenslounge.com/viewtopic.php?f=27&t=38331
Range("A2").Resize((UBound(Split(Range("A2").Value & "," & Range("B2").Value, ",")) + 1) / 2, 2).Value = Application.Index(Split(Range("A2").Value & "," & Range("B2").Value, ","), Evaluate("=Row(1:" & (UBound(Split(Range("A2").Value & "," & Range("B2").Value, ",")) + 1) / 2 & ")/Row(1:" & (UBound(Split(Range("A2").Value & "," & Range("B2").Value, ",")) + 1) / 2 & ")*Column(A:B)/Column(A:B)"), Evaluate("=Row(1:" & (UBound(Split(Range("A2").Value & "," & Range("B2").Value, ",")) + 1) / 2 & ")+((Column(A:B)-1)*" & (UBound(Split(Range("A2").Value & "," & Range("B2").Value, ",")) + 1) / 2 & ")"))
End Sub
In actual fact, we can simplify things a bit , since Intersexual interception theory (https://excelfox.com/forum/showthread.php/2145-Excel-VBA-Interception-and-Implicit-Intersection-and-VLookUp) tells us that if Excel is looking for the indicies of this form
A b
C d
E f
G h
, but we only give it
1
, then it will see this instead
1 1
1 1
1 1
1 1
So that means we can replace Rws() with just 1
So that all simplifies it a bit…
Sub SplitData4b()
Dim Ws2 As Worksheet: Set Ws2 = ThisWorkbook.Worksheets.Item("Sheet2")
Dim strDta As String: Let strDta = Ws2.Range("A2").Value & "," & Ws2.Range("B2").Value
Dim arrIn() As String
Let arrIn() = Split(strDta, ",", -1, vbBinaryCompare)
' Or
arrIn() = Split(Range("A2").Value & "," & Range("B2").Value, ",")
'Dim Rws() As Variant
' Let Rws() = Evaluate("=Row(1:4)/Row(1:4)*Column(A:B)/Column(A:B)")
' Let Rws() = Evaluate("=Row(1:" & (UBound(arrIn()) + 1) / 2 & ")/Row(1:" & (UBound(arrIn()) + 1) / 2 & ")*Column(A:B)/Column(A:B)")
Dim Clms() As Variant
Let Clms() = Evaluate("=Row(1:4)+((Column(A:B)-1)*" & (UBound(arrIn()) + 1) / 2 & ")")
Let Clms() = Evaluate("=Row(1:" & (UBound(arrIn()) + 1) / 2 & ")+((Column(A:B)-1)*" & (UBound(arrIn()) + 1) / 2 & ")")
Dim arrOut() As Variant
' Let arrOut() = Application.Index(arrIn(), Rws(), Clms())
Let arrOut() = Application.Index(arrIn(), 1, Clms())
Let Ws2.Range("A2").Resize((UBound(arrIn()) + 1) / 2, 2).Value = arrOut()
' Or
' Range("A2").Resize((UBound(arrIn()) + 1) / 2, 2).Value = arrOut()
' Range("A2").Resize((UBound(arrIn()) + 1) / 2, 2).Value = Application.Index(arrIn(), 1, Clms())
' Range("A2").Resize((UBound(arrIn()) + 1) / 2, 2).Value = Application.Index(arrIn(), 1, Evaluate("=Row(1:" & (UBound(arrIn()) + 1) / 2 & ")+((Column(A:B)-1)*" & (UBound(arrIn()) + 1) / 2 & ")"))
Range("A2").Resize((UBound(Split(Range("A2").Value & "," & Range("B2").Value, ",")) + 1) / 2, 2).Value = Application.Index(Split(Range("A2").Value & "," & Range("B2").Value, ","), 1, Evaluate("=Row(1:" & (UBound(Split(Range("A2").Value & "," & Range("B2").Value, ",")) + 1) / 2 & ")+((Column(A:B)-1)*" & (UBound(Split(Range("A2").Value & "," & Range("B2").Value, ",")) + 1) / 2 & ")"))
End Sub
Sub StantiallyBeautifulb() ' http://www.eileenslounge.com/viewtopic.php?f=27&t=38331
Range("A2").Resize((UBound(Split(Range("A2").Value & "," & Range("B2").Value, ",")) + 1) / 2, 2).Value = Application.Index(Split(Range("A2").Value & "," & Range("B2").Value, ","), 1, Evaluate("=Row(1:" & (UBound(Split(Range("A2").Value & "," & Range("B2").Value, ",")) + 1) / 2 & ")+((Column(A:B)-1)*" & (UBound(Split(Range("A2").Value & "," & Range("B2").Value, ",")) + 1) / 2 & ")"))
End Sub
DocAElstein
06-22-2022, 12:42 PM
some more notes on it....
later.....
' http://services.runescape.com/m=forum/forums.ws?278,279,877,64690220
'Msg = Msg & Choose(Color, "black", "blue", "darkgreen") & "]"
Msg = Msg & Choose(Color, "blue", "blueviolet", "darkgreen") & "]" ' Custom Colors Wonk
Msg = Msg & Text
'Converts the specified text with the VBE Color (Black, Blue or Green) using BB code
Private Function BBColor(ByVal Color As Long, ByVal Text As String) As String
Dim Msg As String
Msg = "' http://services.runescape.com/m=forum/forums.ws?278,279,877,64690220
'Msg = Msg & Choose(Color, "black", "blue", "darkgreen") & "]"
Msg = Msg & Choose(Color, "blue", "blueviolet", "darkgreen") & "]" ' Custom Colors Wonk
Msg = Msg & Text
Msg = Msg & ""
BBColor = Msg
End Function[/color]
'Converts the specified text with the VBE Color (Black, Blue or Green) using BB code
Private Function BBColor(ByVal Color As Long, ByVal Text As String) As String
Dim Msg As String
Msg = "' http://services.runescape.com/m=forum/forums.ws?278,279,877,64690220
'Msg = Msg & Choose(Color, "black", "blue", "darkgreen") & "]"
' Msg = Msg & Choose(Color, "blue", "blueviolet", "darkgreen") & "]" ' Custom Colors Wonk
Msg = Msg & Choose(Color, "blue", "darkblue", "darkgreen") & "]" ' Custom Colors Wonk Serszud2 July 2023
Msg = Msg & Text
Msg = Msg & ""
BBColor = Msg
End Function
[/color]
Option Explicit
Sub SeeIfThisWorks3() ' https://eileenslounge.com/viewtopic.php?p=309137#p309137
Dim Rng As Range
Set Rng = Worksheets.Item("Sheet1").Range("A1:F4")
Let Rng.Value = Evaluate("=IF(" & Rng.Address & "="""","""",IF(ISNUMBER(" & Rng.Address & "),1*" & Rng.Address & "," & Rng.Address & "))")
End Sub
Msg = Msg & Choose(Color, "blue", "darkblue", "darkgreen") & "]" ' Custom Colors Wonk Serszud2 July 2023
Option Explicit
Sub SeeIfThisWorks3() ' https://eileenslounge.com/viewtopic.php?p=309137#p309137
Dim Rng As Range
Set Rng = Worksheets.Item("Sheet1").Range("A1:F4")
Let Rng.Value = Evaluate("=IF(" & Rng.Address & "="""","""",IF(ISNUMBER(" & Rng.Address & "),1*" & Rng.Address & "," & Rng.Address & "))")
End Sub
DocAElstein
06-22-2022, 12:43 PM
This is post https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16643&viewfull=1#post16643
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16643&viewfull=1#post16643
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page54#post16643
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page54#post16643
Some more notes related to these posts
http://www.eileenslounge.com/viewtopic.php?f=27&t=38331&p=296482#p296482
Making it more flexible / dynamic, most for academic interest and aesthetic Pleasure
The code is flexible already in terms of the number of elements in each cell, ( but note The macro assumes the cells all have the same number of elements - like __ 1,2,3,4 __ t,y,u,m __ 5,6,7,8 __ a,b,c,d )
This post extends the flexibility to a dynamic number of cells used. ( While I was writing this, the OP asked for a mod to increase the used cells from 2 to 4, so a flexible solution is , as often, worthwhile )
We almost certainly need to know how many cells we have, and the usual way is done to get that,
__ Lc = Ws1.Cells(2, Ws1.Columns.Count).End(xlToLeft).Column
Join an array of the cells
The key to the new flexible solution is to Join the elements of an array with a comma, where the elements are the cell values, which themselves are separated already with a comma. (So then as previously, we then finally have a single string of comma separated values, which we , as previously split by a comma, to give us our single array of all data values.
Initially we can get an array of cell values from applying the .Value property to our multi cell range.
Something of this sort of form, for example, for if we had 4 cells in the second row,
_________arrCels2D1Row() = Ws1.Range("A2:D2").Value2
A small snag here is that the array returned by the .Value property, is a 1 row, 2 Dimensional array, ( a pseudo “horizontal” , “single width” array) but the VBA strings Join function only accepts a 1 dimensional array. However, it’s a strange characteristic of VBA that many things if they are asked to return something in the orientation of pseudo “horizontal” , “single width” , then they return a 1 Dimensional array: It seems that somehow the internal workings often relate a row orientation to a single dimensional array. ( This is convenient to think about, as is the idea of pseudo “horizontal” , “single width” , since in the case of a 1 dimensional array we often write it in a line like {1, 2, 3, 6, "z"} , but we should remember that strictly speaking academically orientation in arrays is subjective. )
As example this seemingly redundant code line takes the first row from our single row 2 Dimensional array: Seemingly useless, but in fact it returns the 1 Dimensional array of cell values, as we require, -
___ arrCels1D() = Application.Index(arrCels2D1Row(), 1, 0)
___ ___ - Effectively that converts a 2 Dimensional 1 row array into a 1 Dimensional array, and why VBA has that sort of strange characteristic thing is not clearly known
After this, we simply modify the previous solutions to replace some hard coded values with the dynamic Lc: For example we see the number 2 used frequently, when we originally had 2 cells, and this will likely need to be replaced by Lc, and correspondingly we used B in places where this will likely need to be replaced by the column letter corresponding to column Lc
Unfortunately, the final single code line does not quite fit on one line, but it is one code line, but needs to be split to get it in the VB Editor
Sub PrettydammBeautiful()
Range("A2").Resize((UBound(Split(Join(Application.Index(Rang e("A2:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & "2").Value2, 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column, Cells(2, Columns.Count).End(xlToLeft).Column).Value = _
Application.Index(Split(Join(Application.Index(Ran ge("A2:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & "2").Value2, 1, 0), ","), ","), 1, Evaluate("=Row(1:" & (UBound(Split(Join(Application.Index(Range("A2:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & "2").Value2, 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column & ")+((Column(A:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & ")-1)*" & (UBound(Split(Join(Application.Index(Range("A2:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & "2").Value2, 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column & ")"))
End Sub
Here the full story: see next post
DocAElstein
06-24-2022, 03:56 PM
Here is the full workings for the last macro from the last post
Sub SplitDataFlexibly() '
Rem 1 worksheets data info
Dim Ws1 As Worksheet: Set Ws1 = ThisWorkbook.Worksheets.Item("Sheet1")
Dim Lc As Long: Let Lc = Ws1.Cells(2, Ws1.Columns.Count).End(xlToLeft).Column: Lc = Cells(2, Columns.Count).End(xlToLeft).Column
Rem 2 create a 1 Dimensional array of all data
Dim LCL As String: Let LCL = Split(Cells(1, Lc).Address, "$", 3, vbBinaryCompare)(1): LCL = Split(Cells(1, Lc).Address, "$")(1) ' what we are doing is splitting like $D$1 by the $ and then taking the second element, in the example that will be D
Dim arrCels2D1Row() As Variant: Let arrCels2D1Row() = Ws1.Range("A2:" & LCL & "2").Value2
Dim arrCels1D() As Variant: Let arrCels1D() = Application.Index(arrCels2D1Row(), 1, 0)
Dim strDta As String: Let strDta = Join(arrCels1D(), ",") 'Ws2.Range("A2").Value & "," & Ws2.Range("B2").Value
Rem 3 Making previous solution dynamic, - requires changing B with " & LCL & " and some hard coded occurasnces of 2 with Lc
Dim arrIn() As String
Let arrIn() = Split(strDta, ",", -1, vbBinaryCompare)
' Or
arrIn() = Split(Join(arrCels1D(), ","), ",")
Dim Clms() As Variant
' the next lines, used in previous example. is for the case of two cells, so we need to change some hard coded stuff to make the solution dynamic. ' Let Clms() = Evaluate("=Row(1:4)+((Column(A:B)-1)*" & (UBound(arrIn()) + 1) / 2 & ")")
' Let Clms() = Evaluate("=Row(1:" & (UBound(arrIn()) + 1) / 2 & ")+((Column(A:B)-1)*" & (UBound(arrIn()) + 1) / 2 & ")")
Let Clms() = Evaluate("=Row(1:" & (UBound(arrIn()) + 1) / Lc & ")+((Column(A:" & LCL & ")-1)*" & (UBound(arrIn()) + 1) / Lc & ")")
Dim arrOut() As Variant
Let arrOut() = Application.Index(arrIn(), 1, Clms())
' Let Ws2.Range("A2").Resize((UBound(arrIn()) + 1) / 2, 2).Value = arrOut() ' This was the case for 2 cells
Let Ws1.Range("A2").Resize((UBound(arrIn()) + 1) / Lc, Lc).Value = arrOut()
' Or
' Range("A2").Resize((UBound(arrIn()) + 1) / Lc, Lc).Value = arrOut()
' Range("A2").Resize((UBound(arrIn()) + 1) / Lc, Lc).Value = Application.Index(arrIn(), 1, Clms())
' Range("A2").Resize((UBound(arrIn()) + 1) / Lc, Lc).Value = Application.Index(arrIn(), 1, Evaluate("=Row(1:" & (UBound(arrIn()) + 1) / Lc & ")+((Column(A:" & LCL & ")-1)*" & (UBound(arrIn()) + 1) / Lc & ")"))
' Range("A2").Resize((UBound(Split(Join(arrCels1D(), ","), ",")) + 1) / Lc, Lc).Value = Application.Index(Split(Join(arrCels1D(), ","), ","), 1, Evaluate("=Row(1:" & (UBound(arrIn()) + 1) / Lc & ")+((Column(A:" & LCL & ")-1)*" & (UBound(arrIn()) + 1) / Lc & ")"))
' Range("A2").Resize((UBound(Split(Join(arrCels1D(), ","), ",")) + 1) / Lc, Lc).Value = Application.Index(Split(Join(arrCels1D(), ","), ","), 1, Evaluate("=Row(1:" & (UBound(Split(Join(arrCels1D(), ","), ",")) + 1) / Lc & ")+((Column(A:" & LCL & ")-1)*" & (UBound(Split(Join(arrCels1D(), ","), ",")) + 1) / Lc & ")"))
' Range("A2").Resize((UBound(Split(Join(Application.Index(arrC els2D1Row(), 1, 0), ","), ",")) + 1) / Lc, Lc).Value = Application.Index(Split(Join(Application.Index(arr Cels2D1Row(), 1, 0), ","), ","), 1, Evaluate("=Row(1:" & (UBound(Split(Join(Application.Index(arrCels2D1Row (), 1, 0), ","), ",")) + 1) / Lc & ")+((Column(A:" & LCL & ")-1)*" & (UBound(Split(Join(Application.Index(arrCels2D1Row (), 1, 0), ","), ",")) + 1) / Lc & ")"))
' Range("A2").Resize((UBound(Split(Join(Application.Index(Ws1. Range("A2:" & LCL & "2").Value2, 1, 0), ","), ",")) + 1) / Lc, Lc).Value = Application.Index(Split(Join(Application.Index(Ws1 .Range("A2:" & LCL & "2").Value2, 1, 0), ","), ","), 1, Evaluate("=Row(1:" & (UBound(Split(Join(Application.Index(Ws1.Range("A2:" & LCL & "2").Value2, 1, 0), ","), ",")) + 1) / Lc & ")+((Column(A:" & LCL & ")-1)*" & (UBound(Split(Join(Application.Index(arrCels2D1Row (), 1, 0), ","), ",")) + 1) / Lc & ")"))
' Range("A2").Resize((UBound(Split(Join(Application.Index(Ws1. Range("A2:" & Split(Cells(1, Lc).Address, "$")(1) & "2").Value2, 1, 0), ","), ",")) + 1) / Lc, Lc).Value = Application.Index(Split(Join(Application.Index(Ws1 .Range("A2:" & Split(Cells(1, Lc).Address, "$")(1) & "2").Value2, 1, 0), ","), ","), 1, Evaluate("=Row(1:" & (UBound(Split(Join(Application.Index(Ws1.Range("A2:" & LCL & "2").Value2, 1, 0), ","), ",")) + 1) / Lc & ")+((Column(A:" & Split(Cells(1, Lc).Address, "$")(1) & ")-1)*" & (UBound(Split(Join(Application.Index(arrCels2D1Row (), 1, 0), ","), ",")) + 1) / Lc & ")"))
' Range("A2").Resize((UBound(Split(Join(Application.Index(Rang e("A2:" & Split(Cells(1, Lc).Address, "$")(1) & "2").Value2, 1, 0), ","), ",")) + 1) / Lc, Lc).Value = Application.Index(Split(Join(Application.Index(Ran ge("A2:" & Split(Cells(1, Lc).Address, "$")(1) & "2").Value2, 1, 0), ","), ","), 1, Evaluate("=Row(1:" & (UBound(Split(Join(Application.Index(Range("A2:" & LCL & "2").Value2, 1, 0), ","), ",")) + 1) / Lc & ")+((Column(A:" & Split(Cells(1, Lc).Address, "$")(1) & ")-1)*" & (UBound(Split(Join(Application.Index(arrCels2D1Row (), 1, 0), ","), ",")) + 1) / Lc & ")"))
' Range("A2").Resize((UBound(Split(Join(Application.Index(Rang e("A2:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & "2").Value2, 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column, Cells(2, Columns.Count).End(xlToLeft).Column).Value = Application.Index(Split(Join(Application.Index(Ran ge("A2:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & "2").Value2, 1, 0), ","), ","), 1, Evaluate("=Row(1:" & (UBound(Split(Join(Application.Index(Range("A2:" & LCL & "2").Value2, 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column & ")+((Column(A:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & ")-1)*" & (UBound(Split(Join(Application.Index(arrCels2D1Row (), 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column & ")"))
' Range("A2").Resize((UBound(Split(Join(Application.Index(Rang e("A2:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & "2").Value2, 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column, Cells(2, Columns.Count).End(xlToLeft).Column).Value = Application.Index(Split(Join(Application.Index(Ran ge("A2:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & "2").Value2, 1, 0), ","), ","), 1, Evaluate("=Row(1:" & (UBound(Split(Join(Application.Index(Range("A2:" & Split(Cells(1, Lc).Address, "$")(1) & "2").Value2, 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column & ")+((Column(A:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & ")-1)*" & (UBound(Split(Join(Application.Index(arrCels2D1Row (), 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column & ")"))
' Range("A2").Resize((UBound(Split(Join(Application.Index(Rang e("A2:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & "2").Value2, 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column, Cells(2, Columns.Count).End(xlToLeft).Column).Value = Application.Index(Split(Join(Application.Index(Ran ge("A2:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & "2").Value2, 1, 0), ","), ","), 1, Evaluate("=Row(1:" & (UBound(Split(Join(Application.Index(Range("A2:" & Split(Cells(1, Lc).Address, "$")(1) & "2").Value2, 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column & ")+((Column(A:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & ")-1)*" & (UBound(Split(Join(Application.Index(Range("A2:" & LCL & "2").Value2, 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column & ")"))
' Range("A2").Resize((UBound(Split(Join(Application.Index(Rang e("A2:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & "2").Value2, 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column, Cells(2, Columns.Count).End(xlToLeft).Column).Value = Application.Index(Split(Join(Application.Index(Ran ge("A2:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & "2").Value2, 1, 0), ","), ","), 1, Evaluate("=Row(1:" & (UBound(Split(Join(Application.Index(Range("A2:" & Split(Cells(1, Lc).Address, "$")(1) & "2").Value2, 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column & ")+((Column(A:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & ")-1)*" & (UBound(Split(Join(Application.Index(Range("A2:" & Split(Cells(1, Lc).Address, "$")(1) & "2").Value2, 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column & ")"))
Range("A2").Resize((UBound(Split(Join(Application.Index(Rang e("A2:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & "2").Value2, 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column, Cells(2, Columns.Count).End(xlToLeft).Column).Value = _
Application.Index(Split(Join(Application.Index(Ran ge("A2:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & "2").Value2, 1, 0), ","), ","), 1, Evaluate("=Row(1:" & (UBound(Split(Join(Application.Index(Range("A2:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & "2").Value2, 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column & ")+((Column(A:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & ")-1)*" & (UBound(Split(Join(Application.Index(Range("A2:" & Split(Cells(1, Cells(2, Columns.Count).End(xlToLeft).Column).Address, "$")(1) & "2").Value2, 1, 0), ","), ",")) + 1) / Cells(2, Columns.Count).End(xlToLeft).Column & ")"))
End Sub
DocAElstein
07-17-2022, 12:10 PM
In support of this main Forum post:
http://www.eileenslounge.com/viewtopic.php?p=297074#p297074 http://www.eileenslounge.com/viewtopic.php?p=297074#p297074
First overcomplicated Solution
Hello
.... in real these values will go to another WBK.
:::
or now just one question, "public" will always declare for userfrom means storing value either within WBK or for Other WBK.
Public means that the variable will be "known" in all code modules of the same workbook, but not in code modules in other open workbooks. .
If Public variables are being the things that go in a normal code module, as I think they are, technically, or officially, or words to that effect, then that is the case that they won’t be known in other workbooks.
In other words, for the purposes of what is going on here, it means you will need to be storing them in the same workbook, as Hans said, and how he demonstrated.
However, you can do something that technically is not involving Public variables, but as far as I can tell, to all intents and purposes, is in effect the same thing as if you could have those Public variable in a different workbook.
The short story is:
Instead of putting the two public variables in a standard normal code module, ( in the same workbook) as Hans did, we can put them in any Class object code module in any open workbook. Technically they are not called Public variables. They are , I think, properties of the instantiated Class object, and we can access them, in the usual way that we access properties of an object.
The full story
PurseWayDoughPublicVariables.xls
I have another workbook uploaded, PurseWayDoughPublicVariables.xls . That is just to hold these variables. (I will call them “pseudo” Public variables, just because I feel like it :) ),
I can put them in any Class object code module, but just for fun, I will put C1 in a worksheet code module, and C2 in the ThisWorkbook code module.
So, this is what Hans did, public variables in a standard normal module like
Standard module, Module1
Public C1 As String
Public C2 As String
Instead of doing that , I will put those variables in Class object code modules in PurseWayDoughPublicVariables.xls, like this:
Worksheet code module, Sheet1
Public C1 As String
'
'
'
Sub PhilC1(ByVal Wrd As String)
Let C1 = Wrd
End Sub
Workbook code module, ThisWorkbook
Public C2 As String
'
'
'
Sub PhilC2(ByVal Wrd As String)
Let C2 = Wrd
End Sub
*** The reason for those extra macros that fill the variables will be apparent shortly….
_.__________________________________-
Sample for Eli.xlsm
I need to modify now the workbook uploaded by Hans, in 3 main ways:
_(i) I don’t need the two public variables in a standard normal code module anymore
_(ii) I need to modify slightly how I reference the variables
Sub Fi_l()
'Act_ive
'Let Range("A2").Resize(10).Value = C1
Let Range("A2").Resize(10).Value = Workbooks("PurseWayDoughPublicVariables.xls").Worksheets("Sheet1").C1
'let Range("B2").Resize(10).Value = C2
Let Range("B2").Resize(10).Value = Workbooks("PurseWayDoughPublicVariables.xls").C2
End Sub
_(iii) Filling the variable is slightly more tricky. As far as I know, I can’t easily directly fill them from a macro in Sample for Eli.xlsm. - ***Edit: not true - see next post!! But I can run those extra macros*** that fill the variables, from Sample for Eli.xlsm
So to do that I modify the coding in the UserForm thus, ( for the purposes of this demo, I assume the two workbooks are stored in the same place):
Private Sub CommandButton1_Click()
Select Case Me.CheckBox1
Case True
'C1 = "yes"
Application.Run Macro:="'" & ThisWorkbook.Path & "\" & "PurseWayDoughPublicVariables.xls'!Sheet1.PhilC1", Arg1:="Yus"
End Select
Select Case Me.CheckBox2
Case True
'C2 = "yes"
Application.Run Macro:="'" & ThisWorkbook.Path & "\" & "PurseWayDoughPublicVariables.xls'!ThisWorkbook.Phi lC2", Arg1:="Ja"
End Select
Unload Me
Call Sheet2.Fi_l
End Sub
_.____
That’s it. So download both files, store them in the same place, and then the coding in Sample for Eli.xlsm should work as before. The only difference is that you are using the “pseudo” public variables in the workbook PurseWayDoughPublicVariables.xls
_.________________________________________________ _____________________
I have not seen this use of “pseudo” public variables much before, so there may be some reason I don’t know about why they should not be used??
But I use them myself sometimes, and so far I have never seen them behave any differently to “proper” public variables
( I would just finally say that I don’t use public variables much myself, pseudo or otherwise, if I can find another way to do what I want. I don’t like public variables myself. For one reason: I find they have an annoying habit of getting emptied sometimes. )
Alan
Ref
https://stackoverflow.com/questions/42908101/run-code-in-worksheets-class-code-module-in-another-workbook#
https://excelfox.com/forum/showthread.php/2404-Notes-tests-Application-Run-OnTime-Multiple-Variable-Arguments-ByRef-ByVal?p=11870&viewfull=1#post11870
https://stackoverflow.com/questions/31439866/multiple-variable-arguments-to-application-ontime/59812342#59812342
https://www.mrexcel.com/board/threads/reading-a-global-variable-from-another-workbook.963503/#post-4629654
DocAElstein
07-17-2022, 12:58 PM
In support of this main Forum post:
http://www.eileenslounge.com/viewtopic.php?p=297074#p297074 http://www.eileenslounge.com/viewtopic.php?p=297074#p297074
Second simplified Solution
I think in the first solution I made initially a mistake in trying to set the pseudo public variables, *** and so went off in a tangent using the Application.Run stuff. You don’t need any of that and can forget the two macros that fill the variables as well.
You just need this
Worksheet code module, Sheet1 ( in PurseWayDoughPublicVariables.xls )
Public C1 As String
Workbook code module, ThisWorkbook ( in PurseWayDoughPublicVariables.xls )
Public C2 As String
And then the other macros are like
Private Sub CommandButton1_Click()
Select Case Me.CheckBox1
Case True
'C1 = "yes"
' Application.Run Macro:="'" & ThisWorkbook.Path & "\" & "PurseWayDoughPublicVariables.xls'!Sheet1.PhilC1", Arg1:="Yus"
Let Workbooks("PurseWayDoughPublicVariables.xls").Worksheets("Sheet1").C1 = "Yus"
End Select
Select Case Me.CheckBox2
Case True
'C2 = "yes"
' Application.Run Macro:="'" & ThisWorkbook.Path & "\" & "PurseWayDoughPublicVariables.xls'!ThisWorkbook.Phi lC2", Arg1:="Ja"
Let Workbooks("PurseWayDoughPublicVariables.xls").C2 = "Ja"
End Select
Unload Me
Call Sheet2.Fi_l
End Sub
Sub Fi_l()
'Act_ive
'Let Range("A2").Resize(10).Value = C1
Let Range("A2").Resize(10).Value = Workbooks("PurseWayDoughPublicVariables.xls").Worksheets("Sheet1").C1
'let Range("B2").Resize(10).Value = C2
Let Range("B2").Resize(10).Value = Workbooks("PurseWayDoughPublicVariables.xls").C2
End Sub
DocAElstein
07-22-2022, 12:03 PM
Some extra notes for this Thread:
http://www.eileenslounge.com/viewtopic.php?f=30&t=38460
Hans Solution http://www.eileenslounge.com/viewtopic.php?p=297266#p297266
This is a nice solution which I totally misread, or rather in my ignorance, I did not understand.
The main point I missed is…
The solution assumes that the final solution actually has a 26 element 1 dimensional array, and the weight numbers in that array are sorted in alphabetical order, so that the first element represents the weight for “A” and the last Element represents the weight for “Z”, etc.
( So the array Letters() is redundant, and only the Weights() array is needed )
Hans has kindly set me straight and explained where I was going wrong. The final working version of his solution is
Sub Testit()
MsgBox prompt:=Weight("ZAC")
End Sub
' https://eileenslounge.com/viewtopic.php?f=30&t=38460&sid=4295ec4560088f42492ca29590271a87
Public Function Weight(S As String) As Long ' http://www.eileenslounge.com/viewtopic.php?p=297266#p297266
Dim Weights() As Variant ' Letters() As Variant,
Dim i As Long
' Letters = Array("A", "B", "C", ..., "Z")
' Weights = Array(1, 5, 3, ..., 2)
' A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z
Let Weights() = Array(1, 5, 3, 1, 4, 3, 2, 1, 6, 4, 5, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 2) ' Watch : - : Weights() : : Variant/Variant(0 to 25) : Module1.Weight
For i = 1 To Len(S)
Let Weight = Weight + Weights(Asc(Mid(S, i, 1)) - 65)
Next i
End Function
How is that working:
We are looping through each character, then doing something clever to get the running total. The clever bit is getting the array element
To demonstrate that working consider a couple of examples for the case of a word having an A and a Z in it
A has the Ascii Code number of 65. So we end up referring to Weights(65-65) = Weights(0) , which is the first element typically in a 1 dimensional array that starts at indicia 0
Z has the Ascii Code number of 90. So we end up referring to Weights(90-65) = Weights(25) , which is the last element in a 1 dimensional array of 26 elements that starts at indicia 0
In order for the function to get correct results in the case of lower case letters, then one way to do it, ( assuming you have the correct Weights() array you want for lower case letters), you would need to change the 65 to 97
Sub Testit()
Debug.Print Tab(4); "ASCII"; Tab(12); "Weight"
Debug.Print Tab(4); "Code"
Call Weight("ZAC")
Debug.Print
Call WeightLowerCase("zac")
End Sub
' https://eileenslounge.com/viewtopic.php?f=30&t=38460&sid=4295ec4560088f42492ca29590271a87
Public Function Weight(S As String) As Long ' http://www.eileenslounge.com/viewtopic.php?p=297266#p297266
Dim Weights() As Variant ' Letters() As Variant,
Dim i As Long
' A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z
Let Weights() = Array(1, 5, 3, 1, 4, 3, 2, 1, 6, 4, 5, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 2) ' Watch : - : Weights() : : Variant/Variant(0 to 25) : Module1.Weight
For i = 1 To Len(S)
Let Weight = Weight + Weights(Asc(Mid(S, i, 1)) - 65)
Debug.Print Mid(S, i, 1); Tab(4); Asc(Mid(S, i, 1)); Tab(8); Asc(Mid(S, i, 1)) - 65; Tab(12); Weights(Asc(Mid(S, i, 1)) - 65)
Next i
End Function
Public Function WeightLowerCase(S As String) As Long ' http://www.eileenslounge.com/viewtopic.php?p=297266#p297266
Dim Weights() As Variant ' Letters() As Variant,
Dim i As Long
' a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z
Let Weights() = Array(1, 5, 3, 1, 4, 3, 2, 1, 6, 4, 5, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 2) '
For i = 1 To Len(S)
Let WeightLowerCase = WeightLowerCase + Weights(Asc(Mid(S, i, 1)) - 97)
Debug.Print Mid(S, i, 1) & vbTab & Asc(Mid(S, i, 1)) & vbTab & Asc(Mid(S, i, 1)) - 97 & vbTab & Weights(Asc(Mid(S, i, 1)) - 97)
Next i
End Function
Here is the Debug.Print output from the last demo coding
ASCII Weight
Code
Z 90 25 2
A 65 0 1
C 67 2 3
z 122 25 2
a 97 0 1
c 99 2 3
DocAElstein
07-24-2022, 12:02 PM
Here is an alternative single liner ( almost ## ) type solution to the last post. It was much simpler than I expected, and ends up much shorter than these solutions of mine usually do. (## There was a small snag, not solved yet, which means I have to do it in 2 code lines for now. I may take a look at that later here: https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16655&viewfull=1#post16655 )
Solution explanation.
Part 1. Background
This is all to do with
_ “my”** ____arrOut()=Index(ArrIn(), Rws(), Clms()) ______ type solutions, ( https://www.excelforum.com/excel-new-users-basics/1099995-application-index-with-look-up-rows-and-columns-arguments-as-vba-arrays.html#post4571172 )
and also
_ using the Match in a similar way – ( some time ago I obsessed with trying out Application.Match where the first argument is an array, in a similar way to those of those array arguments Rws() and Clms() in Index. I got so obsessed I littered a sub forum with over long posts until they deleted them all and limited the post size to stop me doing it again. With hindsight, not a bad thing to do, as I could not see the wood for the trees back then. I can now, and its not at all difficult to understand, so I really don’t need all that crap anymore. Let me call that for now “my” **
________arrOut() = Match(arrArg1(), arrIn() , 0 ) ___ type solution.
( ** I use the word “my” lightly. – I learnt all this stuff from looking at stuff from Rick Rothstein and snb. ( I am not sure if they “invented it” , or got it from other peoples stuff. if I added anything “new” , it might be some of my detailed explanations, which whilst I don’t know if they are correct, they seem to be a valid theory as they go a long way to explain the results ) )
Here is a quick demo of how
_ my ____arrOut()=Match(arrArg1(), arrIn() , 0 ) ____ works
Ordinarily, or most usually the first argument is just one thing that you are looking for. As far as I know all documentation tells you that the way Match in Excel works is, ( simplified ) :
_... you look in the second argument array of things for the thing in the first argument, and , assuming you find it, return the position along where it is, pseudo like
_____ Match( b , { a, b, c } , 0 ) = 2
In the practice we sometimes, ( not always ) , find that things in Excel will work with array arguments and return a corresponding array of outputs. So taking that last example, pseudo like
_____ Match( {b, a} , { a, b, c } , 0 ) = {2, 1}
So that is a bit of theory out of the way. ( I have done a fuller explanation in a few places of how the Application.Index with Look Up Rows and Columns Arguments as VBA Arrays works in a few places
https://excelfox.com/forum/showthread.php/2788-Explain-App-Index(Rng-Rws()-Clms())-(multicolumn-Combobox-with-Index-application)?p=16455&viewfull=1#post16455
https://www.excelforum.com/excel-new-users-basics/1099995-application-index-with-look-up-rows-and-columns-arguments-as-vba-arrays.html#post4571172 )
Part 2. Here is my solution examples
Refering to the first long macro below:
Rem1 is just making some stuff I need for the demo. I use the string example of “ZAC” as per the original OP example http://www.eileenslounge.com/viewtopic.php?f=30&t=38460 . For reasons given in the next bit, I make an array of the 26 Ascii Code numbers for the capital alphabet characters, A, B. C ….Z , Asskeys() = { 65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81 ,82,83,84,85,86,87,88,89,90 }
My array of the weights values, Weights(), for the characters will be the same size as Asskeys() and will have the corresponding weight value for each of the 26 characters in the same order.
Once again it will be clear why later. For now, the point is to have arrays of the same size with related things in the same order
' ' Ascii Code 65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81 ,82,83,84,85,86,87,88,89,90
' ' A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z
' Let Weights() = Array(1, 5, 3, 1, 4, 3, 2, 1, 6, 4, 5, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 2)
Rem 2
I found a way on the internet to turn my string example into an array of single characters, which is what I will be feeding into my Match as first argument. ( Unfortunately it does not return in each element the character, but rather its Ascii Code. But for my purposes that’s just as good.
Rem 3 Match
This is the Match bit, and it tells me the position along where I find the three Ascii Code numbers of “ZAC” in the Ascii Code array, Asskeys()
We get from match here, a 3 element array, MtchRes(), of the position along, of the characters in “ZAC” in the array Asskeys(). We have organised that the array of weights is organised in the same order, so this will also be the position along of the corresponding weight number in the array of weights, Weights().
In the example we should have then an array like {26, 1, 3} _ ( if you have followed the logic so far, you can see this is like a pseudo Alphabet position of the characters, Z , A , and C __ (But don’t get confused with Ascii codes, which is pseudo like the official position of characters, and defined by some world standard, that Excel knows about. As example, capital A is listed as Ascii code 65, lowercase a is listed as 97 )
Rem 4 Index
The 3 element array of the position along, of the characters in “ZAC” in the array Asskeys(), is effectively the Clms() array we need for a __arrOut()=Index(ArrIn(), Rws(), Clms())__type solution, where the look up array, arrIn() , will be the weights array, Weights()
The returned array from Index , arrOut(), will be an array, of 3 numbers, which are the weight numbers for the example string “ZAC”.
Rem 5
Finally we simply sum the elements of the found weight values, as per the original OP request.
Sub AssKeys()
Rem 1 Make the arrays and other hard coded things for the demo
Dim AssKeys(1 To 26) As Long
Dim Eye As Long
For Eye = 65 To 90 Step 1
Let AssKeys(Eye - 64) = Eye
Next Eye
' OR
' Dim AssKeys() As Variant: Let AssKey() = Array(65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90)
Dim Weights() As Variant:
' Ascii Code 65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81 ,82,83,84,85,86,87,88,89,90
' A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z
Let Weights() = Array(1, 5, 3, 1, 4, 3, 2, 1, 6, 4, 5, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 2)
Dim ZAC As String
Let ZAC = "ZAC" ' This is a demo example text string
Rem 2 String to array
Dim arrZAC() As Byte: Let arrZAC() = StrConv(ZAC, vbFromUnicode) ' https://stackoverflow.com/questions/13195583/split-string-into-array-of-characters
Rem 3 Match
Dim MtchRes() As Variant
Let MtchRes() = Application.Match(arrZAC(), AssKeys(), 0)
Rem 4 Index
Dim arrOut() As Variant
Let arrOut() = Application.Index(Weights(), 1, MtchRes())
Rem 5
Dim Some As Long: Let Some = Application.Sum(arrOut())
End Sub
Here the shortening possibilities
Sub BeautifulAsskeys()
Rem 1 Make the arrays and other hard coded things for the demo
'Dim Asskeys(1 To 26) As Long
'Dim Eye As Long
' For Eye = 65 To 90 Step 1
' Let Asskeys(Eye - 64) = Eye
' Next Eye
' OR
' Dim AssKeys() As Variant: Let AssKey() = Array(65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90)
'Dim Weights() As Variant:
' ' Ascii Code 65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81 ,82,83,84,85,86,87,88,89,90
' ' A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z
' Let Weights() = Array(1, 5, 3, 1, 4, 3, 2, 1, 6, 4, 5, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 2)
'Dim ZAC As String
' Let ZAC = "ZAC" ' This is a demo example text string
Rem 2 String to array
Dim arrZAC() As Byte: Let arrZAC() = StrConv("ZAC", vbFromUnicode) ' https://stackoverflow.com/questions/13195583/split-string-into-array-of-characters
Rem 3 Match
'Dim MtchRes() As Variant
' Let MtchRes() = Application.Match(arrZAC(), Asskeys(), 0)
' Let MtchRes() = Application.Match(StrConv(ZAC, vbFromUnicode), Asskeys(), 0)' this does not work
Rem 4 Index
'Dim arrOut() As Variant
' Let arrOut() = Application.Index(Weights(), 1, MtchRes())
Rem 5
Dim Some As Long: Let Some = Application.Sum(Application.Index(Array(1, 5, 3, 1, 4, 3, 2, 1, 6, 4, 5, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 2), 1, Application.Match(arrZAC(), Array(65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90), 0)))
End Sub
'
Sub AsKeys() ' http://www.eileenslounge.com/viewtopic.php?p=297288#p297288
Dim arrZAC() As Byte: Let arrZAC() = StrConv("ZAC", vbFromUnicode) ' https://stackoverflow.com/questions/13195583/split-string-into-array-of-characters
Dim Some As Long: Let Some = Application.Sum(Application.Index(Array(1, 5, 3, 1, 4, 3, 2, 1, 6, 4, 5, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 2), 1, Application.Match(arrZAC(), Array(65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90), 0)))
End Sub
** I use the word “my” lightly. – I learnt all this stuff from looking at stuff from Rick Rothstein and snb. ( I am not sure if they “invented it” , or got it from other peoples stuff. if I added anything “new” , it might be some of my detailed explanations, which whilst I don’t know if they are correct, they seem to be a valid theory as they go a long way to explain the results
DocAElstein
07-24-2022, 12:49 PM
Spare post for sharing some documents
Ersatzpost für die gemeinsame Nutzung einiger Dokumente
https://i.postimg.cc/c6gJFyYS/Skizze-1-i-and-Skizze-2-ii.jpg (https://postimg.cc/c6gJFyYS)3932
https://i.postimg.cc/WpSJbs1h/Skizze-1-i-and-Skizze-2-ii.jpg (https://postimg.cc/c6gJFyYS)
https://i.postimg.cc/Lhc87CBZ/Skizze-2-i.jpg (https://postimg.cc/Lhc87CBZ)3933
https://i.postimg.cc/Wb3qdxdS/Skizze-2-i.jpg (https://postimg.cc/Lhc87CBZ)
https://i.postimg.cc/D4Xy0LFZ/Skizze-2-ii.jpg (https://postimg.cc/D4Xy0LFZ)3934
https://i.postimg.cc/rshdhNPS/Skizze-2-ii.jpg (https://postimg.cc/D4Xy0LFZ)
AlanSdattHof15Aug2022.docx
https://app.box.com/s/xxntrig04ppe7hdd68se882rm3fv2ysw https://bit.ly/3QXSEv0
AlanSdattHof15Aug2022.doc
https://app.box.com/s/pt4v46nl28qya2bfycgq2rdfz3a35fq8 https://bit.ly/3STVvqm
This post links
AlanSdattHof15Aug2022.docx
AlanSdattHof15Aug2022.doc
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16655&viewfull=1#post16655
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page55#post16655
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16655&viewfull=1#post16655
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page55#post16655
https://bit.ly/3AEPlmM https://bit.ly/3wmjQvh
DocAElstein
08-01-2022, 12:01 PM
In support of this main forum post
https://excelfox.com/forum/showthread.php/2803-Requirement-of-Excel-Formula
Assuming this is data and wanted results from column D
_____ Workbook: DogsNutsFormulas.xlsm ( Using Excel 2007 32 bit )
Row\Col
A
B
C
D
E
F
G
H
I
1CodeValuesCodeValue1Value2Value3Value4
2
1001
2101
1001
2101
5205
2605
9285
3
1001
5205
2604
4256
7458
3555
4
1001
2605
5
1001
9285
6
2604
4256
7
2604
7458
8
2604
3555
9
Worksheet: SimpleUniqueVLookUp
Enter this In D2 via CSE, then drag it down:
=IFERROR(INDEX($A$2:$A$8,MATCH(0,COUNTIF($D$1:D1,$ A$2:$A$8),0)),"")
Row\Col
D
2
=IFERROR(INDEX($A$2:$A$8,MATCH(0,COUNTIF($D$1:D1,$ A$2:$A$8),0)),"")
3
=IFERROR(INDEX($A$2:$A$8,MATCH(0,COUNTIF($D$1:D2,$ A$2:$A$8),0)),"")
Alternative formula for earlier versions of Excel:
=IF(ISERROR(INDEX($A$2:$A$8,MATCH(0,COUNTIF($D$1:D 1,$A$2:$A$8),0))),"",INDEX($A$2:$A$8,MATCH(0,COUNTIF($D$1:D1,$A$2:$A$8 ),0)))
Row\Col
D
2
=IF(ISERROR(INDEX($A$2:$A$8,MATCH(0,COUNTIF($D$1:D 1,$A$2:$A$8),0))),"",INDEX($A$2:$A$8,MATCH(0,COUNTIF($D$1:D1,$A$2:$A$8 ),0)))
3
=IF(ISERROR(INDEX($A$2:$A$8,MATCH(0,COUNTIF($D$1:D 2,$A$2:$A$8),0))),"",INDEX($A$2:$A$8,MATCH(0,COUNTIF($D$1:D2,$A$2:$A$8 ),0)))
Hi Amelynn
…..
If after TextBox(n) it is necessary to put the .text or .value
If not putting anything is wrong (although it works)
What is the difference between the three things……
I can’t answer most of your question here, unfortunately, because
_ I have no experience with Textboxes
_ I am not too familiar with the .Text property.
I can only tell you the small part that I know about: - what I know about is
Range__
Range__.Value
Range__.Value2
Range__ object
Range__ is an object with an extremely large number of properties, methods and various things.
Range__ is all to do with how Excel organises and uses cells. Understanding the Range__ object is probably one of the most important things to know about in Excel and VBA, especially if you are interested in spreadsheet things.
But many times, we are only interested in the value that is in a cell. Because most people are often only interested in the value in a cell, Microsoft have made .Value the default of what you get if you just use Range__. So most of the time if you choose to write just Range__ , then in fact , Excel will not see that, instead it will see and use Range__.Value
It is just personal choice if you choose to use Range__.Value or Range__. Usually there are no problems if you just use Range__ , but I have seen occasions when this caused problems as there may be occasions when Excel tries to refer to the Range__ object instead of the value.
So personally I prefer to always include the .Value if I am interested in a value. I will only leave out the .Value if I am doing something that wants me to reference the Range__ object. Just personal choice.
So, in your example, when you used Worksheets("Sheet1").Range("B10") , Excel did not see and use that.
Instead, Excel saw and used this: Worksheets("Sheet1").Range("B10").Value
....After the range, should I put .text, .value or just nothing? ... So in your examples you could probably just use nothing , but I personally would recommend that you include .Value ( or .Value2 )
But that is just my personally recommendation
.Value or .Value2
.Value is almost the simplest cell value. But not quite. If you are interested in dates or currency, then .Value will show you the date or currency in a date or currency format.
.Value2 is the most simplest cell value as Excel has it held before any formatting is done.
Personally I will use .Value2 most of the time, because it may work a little faster or may be less likely to problems caused by awkward cell formatting issues. I think theoretically it is also a bit more efficient to use .Value2
So….
.....If not putting anything is wrong (although it works)..... It is not wrong to put nothing. But it is bad practice, as it may cause problems in other situations in Excel VBA
(More than half of people put nothing, and they will often get a problem later that they don’t understand )
....Should I necessarily declare that, for example, "Niebla" is a variable of type Str?
The way that you are using "Niebla" in VBA coding is perfectly alright, because: Most of the time in VBA coding, if VBA sees something enclosed in quotes, _ "__" _ , like
"xyz"
, then VBA will take the value of _ xyz _ to be a string.
Even if , in your coding, you did this
"3"
, the VBA would not take the FONT=Courier New]"3"[/FONT] as a number. It would see it as a string, just as it would see this as a string
"I have 3 Apples"
Note that VBA is very user friendly with numbers and strings. For example if you pass it a string like "3" in a function wanting a number, the VBA will not error, but instead it will take a number 3 instead.
In many other computer languages you must be much more careful in defining precisely variable types.
That is as close as I can come to answering your question.
But I do know about Range__ , Range__.Value , Range__.Value2 quite well.
So I am happy to give you any further clarity on those things. Those things are all to do with range referencing in Excel and VBA, which is a very important thing to know about.
Alan
Ref
https://fastexcel.wordpress.com/2011/11/30/text-vs-value-vs-value2-slow-text-and-how-to-avoid-it/
DocAElstein
10-01-2022, 01:21 PM
Some notes in support of this forum main post
https://excelfox.com/forum/showthread.php/2821-Vlookup-and-Match-problem?p=16712&viewfull=1#post16712
An erroring formula: https://i.postimg.cc/nzbWtGTQ/An-erroring-formula.jpg
https://i.postimg.cc/mcjjYMvb/An-erroring-formula.jpg (https://postimg.cc/mcjjYMvb)
Highlight a section, such as the Match section https://i.postimg.cc/5NxZ0pJB/Highlight-match.jpg
https://i.postimg.cc/K4H9pPRj/Highlight-match.jpg (https://postimg.cc/K4H9pPRj)
Hit key F9 https://i.postimg.cc/7P1FwdFP/Hit-key-F9-it-tells-yopu-result-is-5.jpg
https://i.postimg.cc/Thw7c72B/Hit-key-F9-it-tells-yopu-result-is-5.jpg (https://postimg.cc/Thw7c72B)
This reveals that we have 5 , or in total , 5 + 1 = 6
So in the VLookUp we are looking at column 6 in the range given by bk
The names manager tells us which range we want:
Second formula section is the range bk https://i.postimg.cc/JhBFg23L/range-bk.jpg
https://i.postimg.cc/zL8pHpPt/range-bk.jpg (https://postimg.cc/zL8pHpPt)
Similarly we can investigate the first section in the erroring formula
Highlight first formula section https://i.postimg.cc/902syY7j/Highlight-first-formula-section.jpg
Hit key F9 https://i.postimg.cc/wvLStG3V/Hiut-F9-on-highhlighted-first-section.jpg
This reveals that the Look up value, the value that you are looking for is "DMG1"
Further investigations by trial and error , reveals that some character combinations in cell A2 cause the error. But I do not know why yet ?
Examples:
Not work:
https://i.postimg.cc/YqbTmg2J/d-not-work.jpg
https://i.postimg.cc/d0zbVYQ3/d-MG1-not-work.jpg
Works
https://i.postimg.cc/3xq6tTv1/MG1-works.jpg
In fact, it seems that some character combinations are not allowed as the Look Up value generally , for example try another cell, and I can find a character combination that does not work
https://i.postimg.cc/SK204shH/Not-working-some-characters-in-A6.jpg
https://i.postimg.cc/Ff4Cgh1x/Not-working-some-characters-in-A6.jpg (https://postimg.cc/Ff4Cgh1x)
I am puzzled.
In fact if you look in detail at the results you are getting when it does appear to work, then they are not alwaysthe correct values.
https://postimg.cc/kBnt3Zzg
https://i.postimg.cc/kBnt3Zzg/Wrong-resilts-from-VLook-Up.jpg (https://postimg.cc/kBnt3Zzg) https://i.postimg.cc/MKB0RJYV/Wrong-resilts-from-VLook-Up.jpg (https://postimages.org/)
Very strange. I am even more puzzled
?????
Update Answer from Sandy https://excelfox.com/forum/showthread.php/2821-Vlookup-and-Match-problem?p=16717&viewfull=1#post16717
with formula =VLOOKUP(F$26,bk,MATCH($B$24,bkt,1)+1,0) value $1.55 is returned and so on
..just forgot comma on the end or define last argument 0, VLOOKUP(F$26,bk,MATCH($B$24,bkt,1)+1,) so he need to learn how to use VLOOKUP function
VLOOKUP require all arguments, even if last argument is omitted there should be defined place for it after last comma
https://i.postimg.cc/ncHVbyD8/ThatsIt.gif (https://postimages.org/)
https://i.postimg.cc/15VpN7Hj/ThatsIt.jpg https://i.postimg.cc/N5Yy34Z6/ThatsIt.jpg (https://postimg.cc/N5Yy34Z6)
( I thought I had checked that, but missed something somewhere, I don’t know why I missed that, maybe I think also I need to learn how to use VLoopUp properly! )
DocAElstein
10-02-2022, 02:24 PM
Test
I see what you are saying its like “the 14th thing along” , like in if it was in a 1 dimensional or 1 “row” array,
This sort of thing
_number along{1 _ , 2 , 3 , 4 , 5 , 6 , 7 , 8 _ , 9 _ , 10_, 11_, 12_,13 , 14 __ , 15 , _16}
____INDEX({"Part",13,25,37,48,73,101,145,201,289,600,750,1009, "DMG1",4.1,2.85},1,14) = "DMG1"
Or similarly
__number along_____{1 _ , 2 , 3 , 4 , 5 , 6 , 7 , 8 _ , 9 _ , 10_, 11_, 12_,13 , 14 __ , 15 , _16}
__=MATCH("DMG1",{"Part",13,25,37,48,73,101,145,201,289,600,750,1009, "DMG1",4.1,2.85},0) = 14
(Note I must change the row separating ; before the to a column separating , **
I also get indexes mixed up and also I mix up item numbers and indexes. Sometimes they are the same, sometimes they have a similar meaning
( ** just passing interest, if in a range we talk about the “number along” on any range, then we are talking about the range item number, and this “number along” goes like all columns in a row, then next row and so on.
So example in both these ranges, the range item number is 14
Row\ColABCDEFGHIJKLMN
1Part13253748731011452012896007501009DMG1
Range("A1:N1").Item(14) = "DMG1"
Row\ColABCDEFGHIJKLM
1Part13253748731011452012896007501009
2DMG1 $ 4.10 $ 2.85 $ 2.85 $ 1.90 $ 1.55 $ 1.35 $ 1.25 $ 0.95 $ 0.85 $ 0.75 $ 0.75 $ 0.65
Range("A1:M2").Item(14) = "DMG1"
Row\ColOPQRSTUVW
4Part1325374873101145201
52896007501009DMG1 $ 4.10 $ 2.85 $ 2.85 $ 1.90
Range("O4:W5").Item(14) = "DMG1"
Here is a very interesting article by a very clever person on all that https://excelfox.com/forum/showthread.php/2789-Item-way-of-thinking-as-alternative-to-conventional-row-column-looping )
DocAElstein
10-02-2022, 05:49 PM
In support of this forum thread
https://excelfox.com/forum/showthread.php/2818-in-VBA-if-the-given-string-is-found-then-delete-everything-between-two-newlines-where-the-string-appears?p=16718&viewfull=1#post16718
In worksheet String to search is the following:
_____ Workbook: VBA delete everything between two newlines where the string appears.xlsx ( Using Excel 2007 32 bit )
Row\ColA
1
2paragraph/line
3
4searched string
5#VBA
Worksheet: String to search
Here is the given input examples ( The OP gave 4 cells , but for demo here I will put them all in the same code box and separate the 4 examples with a line. Black is the before/input , and Blue the after/ wanted output
in VBA if the given string is found then delete everything between two newlines where the string appears.
"Looking for help in VBA"
if the given string is found in any paragraph/line excel cell then delete everything between two newlines where the string appears. in VBA if the given string is found then delete everything between two newlines where the string appears.
"Looking for help in VBA"searched*string
if the given string is found in any excel cell then delete everything between two newlines where the string appears.
in VBA if the given string is found then delete everything between two newlines where the string appears.
"Looking for help in VBA"
if the given string is found in any excel cell then delete everything between two newlines where the string appears.
in VBA if the given string is found then delete everything between two newlines where the string appears.
"Looking for help in #VBA"
if the given string is found in any excel cell then delete paragraph/line everything between two newlines where the string appears.
in VBA if the given string is found then delete paragraph/line everything between two newlines where the string appears.
"Looking for help in VBA"
if the given string is found in any excel cell then delete everything between two newlines where the string appears.
searched*string
in VBA if the given string is found then delete everything between two newlines where the string appears.
"Looking for help in VBA"
if the given string is found in any excel cell then delete everything between two newlines where the string appears.
in VBA if the given string is found then delete everything between two newlines where the string appears.
"Looking for help in VBA"
if the given string is found in any paragraph/line excel cell then delete everything between two newlines where the string appears. in VBA if the given string is found then delete everything between two newlines where the string appears.
"Looking for help in VBA"searched*string
if the given string is found in any excel cell then delete everything between two newlines where the string appears.
in VBA if the given string is found then delete everything between two newlines where the string appears.
"Looking for help in VBA"
if the given string is found in any excel cell then delete everything between two newlines where the string appears.
in VBA if the given string is found then delete everything between two newlines where the string appears.
"Looking for help in #VBA"
if the given string is found in any excel cell then delete paragraph/line everything between two newlines where the string appears.
in VBA if the given string is found then delete paragraph/line everything between two newlines where the string appears.
"Looking for help in VBA"
if the given string is found in any excel cell then delete everything between two newlines where the string appears.
searched*string
in VBA if the given string is found then delete everything between two newlines where the string appears.
"Looking for help in VBA"
if the given string is found in any excel cell then delete everything between two newlines where the string appears.
OK so it looks quite clear what is needed. The OPs explanation does confirm to this, …. if the given string is found in any excel cell then delete everything between two newlines where the string appears.
… How can I delete sentences with a specific keyword in excel cells in all sheets?
…..but without the example it was much more difficult to understand and may have been interpreted to mean something else..
Putting the explanation of what is wanted a bit clearer, …
There is text in some cells. The text is split into paragraphs or lines, that is to say we see multi-line text, something like
How are you?
Well I am OK Bro today
Enjoying a wank just now.
What we want to do is: Modify the text in cells in this way: If certain words are found in a paragraph or line, then all the text in that line needs to be deleted. Lets say in that example, Bro was one of the words to search for. In that case, the text should be modified so as to look like this
How are you?
Enjoying a wank just now.
We remove all the text, Well I am OK Bro today, but it looks like the lines stay there.
We are manipulating text and some form of line separation is involved, so its usually a good idea to look carefully at the actual characters: Almost immediately I think of Splitting and Joining text where the thing to split by or use to join together will be a text line separator, which can vary. Hence important to take a look, so I will, here, later
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=16727&viewfull=1#post16727
DocAElstein
10-02-2022, 09:33 PM
In support of this main Forum Thread
https://excelfox.com/forum/showthread.php/2819-VBA-keep-only-one-searched-string
Input
"#VBA: keep only one searched string searched string searched string searched string.
#VBA: keep only searched string one searched string.
The list of search stings searchedCSV string searched string is given in sheet 2.
In sheet1, with #VBA check if a given string is CSV searched string found more than once in a paragraph/line. If found more than once then keep only one.
I want to do this both in an excel sheet with CSV searched string multiple column data in multiple rows as well as in a CSV or text file."
"searched string searched string #VBA: keep only one searched string.
#VBA: keep only one searched string.
searched string searched string searched stringThe list of search stings is given in sheet 2.
In sheet1, with #VBA check if a given string is found more than once #VBA #VBA #VBA #VBA #VBA #VBA #VBA #VBA #VBA #VBA #VBA #VBA in a paragraph/line. If found more than once then keep only one. #VBA #VBA #VBA #VBA
I want to do this both in an excel sheet with multiple column data in multiple rows as well as in a CSV or text file."
"#VBA: keep only one searched string.
#VBA: keep only one searched string.
The list of search stings is given in sheet 2.
In sheet1, with #VBA check if a given string is found more than once in a paragraph/line. If found more than once then keep only one.
I want to do this both in an excel sheet with multiple column data in multiple rows as well as in a CSV or text file. #VBA: keep only one searched string.
#VBA: keep only one searched string. searched string searched string searched string searched string
The list of search stings is given in sheet 2. searched string searched string searched string searched string
In sheet1, with #VBA check if a given string is found more than once in a paragraph/line. If found more than once then keep only one.
I want to do this both in an excel sheet with multiple column data in multiple rows as well as in a CSV or text file."
"#VBA: #VBA keep only one searched string.
#VBA: #VBA #VBAkeep only one searched string.
searched string searched string searched string searched string searched string
In sheet1, with #VBA check if a given string is found more than #VBA once in a paragraph/line. If found more than #VBA once then keep only one.
#VBA: keep only one searched string.
The list of search stings is given in sheet 2.
In sheet1, with #VBA check if a given string is found more than #VBA once in a paragraph/line. If found more than #VBA once then keep only one.
I want to do this both in an excel sheet with multiple column data in multiple rows as well as in a CSV or text file."
"#VBA: keep only one searched string.
In sheet1, with #VBA check if a given string is found more than once in a paragraph/line. If found more than once then keep only one.
I want to do this both in an excel sheet with multiple column data in multiple rows as well as in a CSV or text file. #VBA: keep only one searched string.
In sheet1, with #VBA check if a paragraph/line given string is found more than once in a paragraph/line paragraph/line. If found more than once then keep only one.
I want to do this both in an excel sheet with multiple column data in multiple rows as well as in a CSV or text file."
Output
"#VBA: keep only one searched string .
#VBA: keep only searched string one .
The list of search stings searchedCSV string searched string is given in sheet 2.
In sheet1, with #VBA check if a given string is CSV searched string found more than once in a paragraph/line. If found more than once then keep only one.
I want to do this both in an excel sheet with CSV searched string multiple column data in multiple rows as well as in a CSV or text file."
"searched string #VBA: keep only one searched string.
#VBA: keep only one searched string.
searched string searched stringThe list of search stings is given in sheet 2.
In sheet1, with #VBA check if a given string is found more than once in a paragraph/line. If found more than once then keep only one.
I want to do this both in an excel sheet with multiple column data in multiple rows as well as in a CSV or text file."
"#VBA: keep only one searched string.
#VBA: keep only one searched string.
The list of search stings is given in sheet 2.
In sheet1, with #VBA check if a given string is found more than once in a paragraph/line. If found more than once then keep only one.
I want to do this both in an excel sheet with multiple column data in multiple rows as well as in a CSV or text file. #VBA: keep only one searched string.
#VBA: keep only one searched string.
The list of search stings is given in sheet 2. searched string
In sheet1, with #VBA check if a given string is found more than once in a paragraph/line. If found more than once then keep only one.
I want to do this both in an excel sheet with multiple column data in multiple rows as well as in a CSV or text file."
"#VBA: keep only one searched string.
#VBA: keep only one searched string.
searched string
In sheet1, with #VBA check if a given string is found more than once in a paragraph/line. If found more than once then keep only one.
#VBA: keep only one searched string.
The list of search stings is given in sheet 2.
In sheet1, with #VBA check if a given string is found more than once in a paragraph/line. If found more than once then keep only one.
I want to do this both in an excel sheet with multiple column data in multiple rows as well as in a CSV or text file."
"#VBA: keep only one searched string.
In sheet1, with #VBA check if a given string is found more than once in a paragraph/line. If found more than once then keep only one.
I want to do this both in an excel sheet with multiple column data in multiple rows as well as in a CSV or text file. #VBA: keep only one searched string.
In sheet1, with #VBA check if a paragraph/line given string is found more than once in a paragraph/line paragraph/line. If found more than once then keep only one.
I want to do this both in an excel sheet with multiple column data in multiple rows as well as in a CSV or text file."
DocAElstein
10-03-2022, 02:42 PM
In support of this thread
https://excelfox.com/forum/showthread.php/2815-Copy-data-from-multiple-rows-between-two-keyword-and-paste-the-data-in-row(s)-of-single-cell-in-sheet2?p=16710&viewfull=1#post16710
Sheet1 Input in column A
_____ Workbook: VBA row to cell1.xlsx ( Using Excel 2007 32 bit )
Row\ColA
2234. digital marketing information: 2021-2022***….Keywrod1:
2021-2022***
3
4Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
5Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
6
7
8Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
9
10Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
11
12Keywrod1:
13Keyword2: 30000000 *&^%$QWERTY QWERTY
14
15
162344. digital marketing information: 2020-2021***….Keywrod1: *** 2020-2021
digital marketing information
digital marketing information
17
18Digital marketing: =
also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
19Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
20
21Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
22Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
23
24Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
25Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
26Keywrod1: *** 2020-2021
27Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
28Keyword2
29
301. digital marketing information: 2021-2022***….Keywrod1:
2021-2022***
31
32Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
33
34
35QWERTY Keyword2: 30000000 *&^%$QWERTY QWERTY
Worksheet: InputSheet1
"234. digital marketing information: 2021-2022***….Keywrod1:
2021-2022***"
"Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel."
"Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
"
"Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel."
"Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel."
Keywrod1:
Keyword2: 30000000 *&^%$QWERTY QWERTY
"2344. digital marketing information: 2020-2021***….Keywrod1: *** 2020-2021
digital marketing information
digital marketing information"
"Digital marketing: =
also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel."
"Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
"
"Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
"
"Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel."
"Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
"
"Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel."
Keywrod1: *** 2020-2021
"Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel."
Keyword2
"1. digital marketing information: 2021-2022***….Keywrod1:
2021-2022***"
"Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel."
QWERTY Keyword2: 30000000 *&^%$QWERTY QWERTY
Sheet2 Wanted output, next post
DocAElstein
10-03-2022, 02:52 PM
Output required ( https://excelfox.com/forum/showthread.php/2815-Copy-data-from-multiple-rows-between-two-keyword-and-paste-the-data-in-row(s)-of-single-cell-in-sheet2?p=16685&viewfull=1#post16685 )
_____ Workbook: VBA row to cell1.xlsx ( Using Excel 2007 32 bit )
Row\Col
A
2234. digital marketing information: 2021-2022***….Keywrod1:
2021-2022***
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Keywrod1:
Keyword2: 30000000 *&^%$QWERTY QWERTY
32344. digital marketing information: 2020-2021***….Keywrod1: *** 2020-2021
digital marketing information
digital marketing information
Digital marketing: =
also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel."
"Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel."
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel."
Keywrod1: *** 2020-2021
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Keyword2
41. digital marketing information: 2021-2022***….Keywrod1:
2021-2022***
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
QWERTY Keyword2: 30000000 *&^%$QWERTY QWERTY
Worksheet: OutputSheet2
"234. digital marketing information: 2021-2022***….Keywrod1:
2021-2022***
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Keywrod1:
Keyword2: 30000000 *&^%$QWERTY QWERTY"
"2344. digital marketing information: 2020-2021***….Keywrod1: *** 2020-2021
digital marketing information
digital marketing information
Digital marketing: =
also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.""
""Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.""
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.""
Keywrod1: *** 2020-2021
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Keyword2"
"1. digital marketing information: 2021-2022***….Keywrod1:
2021-2022***
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
QWERTY Keyword2: 30000000 *&^%$QWERTY QWERTY"
DocAElstein
10-03-2022, 04:30 PM
Further info for the last two posts
Input ( Sheet1)
_____ Workbook: VBA row to cell1.xlsx ( Using Excel 2007 32 bit )
Row\Col
A
301. digital marketing information: 2021-2022***….Keywrod1:
2021-2022***
31
32Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
33
34
35QWERTY Keyword2: 30000000 *&^%$QWERTY QWERTY
Worksheet: InputSheet1
"1. digital marketing information: 2021-2022***….Keywrod1:
2021-2022***"
"Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel."
QWERTY Keyword2: 30000000 *&^%$QWERTY QWERTY
Output Sheet 2
_____ Workbook: VBA row to cell1.xlsx ( Using Excel 2007 32 bit )
Row\Col
A
41. digital marketing information: 2021-2022***….Keywrod1:
2021-2022***
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
QWERTY Keyword2: 30000000 *&^%$QWERTY QWERTY
Worksheet: OutputSheet2
"1. digital marketing information: 2021-2022***….Keywrod1:
2021-2022***
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
Digital marketing, also called online marketing, is the promotion of brands to
connect with potential customers using the internet and other forms of digital communication.
This includes not only email, social media, and web-based advertising, but also
text and multimedia messages as a marketing channel.
QWERTY Keyword2: 30000000 *&^%$QWERTY QWERTY"
Test
Sept 14 https://www.youtube.com/watch?v=U76ZRIzBhOA https://bit.ly/3EuOh7B
May 14 https://www.youtube.com/watch?v=tPRv-ATUBe4 https://bit.ly/3rMAaTw
May 6 https://www.youtube.com/watch?v=7KPH608Av4E&list=PLc7fktTRMBow1ksFW020hx2XEKabaD5Vd&index=5 https://bit.ly/3TtTlNV
May 4 https://www.youtube.com/watch?v=nDlGkDENCyM https://bit.ly/3MkNUhC
Apr 29 https://www.youtube.com/watch?v=xqBhFPW_LuM&list=PLc7fktTRMBow1ksFW020hx2XEKabaD5Vd&index=6 https://bit.ly/3ejT2WX
DocAElstein
10-04-2022, 02:14 AM
Reduced data
_____ Workbook: VBA row to cell1 reduced data.xls ( Using Excel 2007 32 bit )
Row\Col
A
1
2234. *….Keywrod1:
2021-2022***
3
4This also
text channel.
5Digital to
connect communication.
6
7
8Digital to
connect communication.
This also
text channel.
9
10Keywrod1:
11Keyword2: QWERTY
12
13
142344. ….Keywrod1: *** 2020-2021
digital information
digital information
15
16Digital marketing: =
also to
connect communication.
This also
text channel.
17Digital to
connect communication.
18
19Digital to
connect communication.
This also
text channel.
20Digital to
connect communication.
This also
text channel.
21Keywrod1: *** 2020-2021
22Digital to
connect communication.
This also
text channel.
23Keyword2
24
Worksheet: InputSheet1
"234. *….Keywrod1:
2021-2022***"
"This also
text channel."
"Digital to
connect communication. "
"Digital to
connect communication.
This also
text channel."
Keywrod1:
Keyword2: QWERTY
"2344. ….Keywrod1: *** 2020-2021
digital information
digital information"
"Digital marketing: =
also to
connect communication.
This also
text channel."
"Digital to
connect communication. "
"Digital to
connect communication.
This also
text channel."
"Digital to
connect communication.
This also
text channel."
Keywrod1: *** 2020-2021
"Digital to
connect communication.
This also
text channel."
Keyword2
Output
_____ Workbook: VBA row to cell1 reduced data.xls ( Using Excel 2007 32 bit )
Row\Col
A
2234. *….Keywrod1:
2021-2022***
This also
text channel.
Digital to
connect communication.
Digital to
connect communication.
This also
text channel.
Keywrod1:
Keyword2: QWERTY
32344. ….Keywrod1: *** 2020-2021
digital information
digital information
Digital marketing: =
also to
connect communication.
This also
text channel.
Digital to
connect communication.
Digital to
connect communication.
This also
text channel.
Digital to
connect communication.
This also
text channel.
Keywrod1: *** 2020-2021
Digital to
connect communication.
This also
text channel.
Keyword2
Worksheet: Sheet2
Copy/ Paste
"234. *….Keywrod1:
2021-2022***
This also
text channel.
Digital to
connect communication.
Digital to
connect communication.
This also
text channel.
Keywrod1:
Keyword2: QWERTY"
"2344. ….Keywrod1: *** 2020-2021
digital information
digital information
Digital marketing: =
also to
connect communication.
This also
text channel.
Digital to
connect communication.
Digital to
connect communication.
This also
text channel.
Digital to
connect communication.
This also
text channel.
Keywrod1: *** 2020-2021
Digital to
connect communication.
This also
text channel.
Keyword2"
Copy text from cel or cel .Value
234. *….Keywrod1:
2021-2022***
This also
text channel.
Digital to
connect communication.
Digital to
connect communication.
This also
text channel.
Keywrod1:
Keyword2: QWERTY
2344. ….Keywrod1: *** 2020-2021
digital information
digital information
Digital marketing: =
also to
connect communication.
This also
text channel.
Digital to
connect communication.
Digital to
connect communication.
This also
text channel.
Digital to
connect communication.
This also
text channel.
Keywrod1: *** 2020-2021
Digital to
connect communication.
This also
text channel.
Keyword2
VBA row to cell1 reduced data.xls : https://app.box.com/s/qne60lkrfp30d50w444gedzjg6b7nyat
DocAElstein
10-04-2022, 02:14 AM
s,mfbsabfsbfasf
DocAElstein
10-04-2022, 02:14 AM
In support of this Forum Post
https://eileenslounge.com/viewtopic.php?p=300075&sid=17cbebab1e4e2321a33c5c735aa25802#p300075
I am not to sure if I have a possible solution here, but have some ideas.
This post has some background testing that might help me decide and / or help me get to a possible solution.
This is the problem
why Function isn't working and i also want to know how i can trouble shoot it in UDF (https://eileenslounge.com/viewtopic.php?p=300075&sid=17cbebab1e4e2321a33c5c735aa25802#p300075)
Option Explicit
Function sum_color(a As Range, b As Range) As Long
Dim v As Long, c As Range
For Each c In a
If c.DisplayFormat.Interior.ColorIndex = b.DisplayFormat.Interior.ColorIndex Then
v = v + c.Value
End If
Next c
sum_color = v
End Function
Part of Hans immediate answer was https://eileenslounge.com/viewtopic.php?p=300076#p300076] ( DisplayFormat cannot be used in a UDF [/I]
That spiked my interest and thoughts into things to do with UDFs not liking doing things with Cells other than the cell they are in.
DisplayFormat does not even work in my mostly older Excel versions, such as my older Excel 2007, so first on a Excel 2013 I checked that out. That is mainly what this post is about: trying it out in a slightly newer Excel 2013
Her is the initial results showing , as the OP said, that the UDF in the spreadsheet isn’t working:
https://i.postimg.cc/fSmkbpCN/Book1-Excl2013.jpg (https://postimg.cc/fSmkbpCN)https://i.postimg.cc/R63NkNnq/Book1-Excl2013.jpg (https://postimg.cc/R63NkNnq)
I changed the OPs function a bit, as well as trying it as a simple sub routine, and tried calling both the function and the sub routine from coding
Here my coding versions:
Option Explicit
Sub CallEm()
' From Adeel spreadsheet ' =sum_color(D6:G15;C17) ' http://www.eileenslounge.com/viewtopic.php?p=300075#p300075
Dim ForSubAnswer As Long
Call Subsum_color(Range("D6:G15"), Range("C17"), ForSubAnswer)
Debug.Print ForSubAnswer ' 54
Dim ForFunctionAnswer As Long
Let ForFunctionAnswer = sum_color(Range("D6:G15"), Range("C17"))
Debug.Print ForFunctionAnswer ' 54
End Sub
Public Sub Subsum_color(ByVal a As Range, ByVal b As Range, ByRef RefBack As Long)
Dim v As Long, c As Range
For Each c In a
If c.DisplayFormat.Interior.ColorIndex = b.DisplayFormat.Interior.ColorIndex Then
Let v = v + c.Value
Else
End If
Next c
'Let sum_color = v
Let RefBack = v
End Sub
Public Function sum_color(a As Range, b As Range) As Long
Dim v As Long, c As Range
For Each c In a
If c.DisplayFormat.Interior.ColorIndex = b.DisplayFormat.Interior.ColorIndex Then
Let v = v + c.Value
Else
End If
Next c
Let sum_color = v
End Function
Both the sub routine and the function seem to work in normal coding. https://i.postimg.cc/VSZJZjv3/Correct-Answers-by-call-in-coding.jpg (https://postimg.cc/VSZJZjv3)
https://i.postimg.cc/CxC2n9Ck/Correct-Answers-by-call-in-coding.jpg (https://postimages.org/)
Conclusion
As I was thinking, the problem seems to be something to do with a UDF not liking interacting with other cells in a worksheet
DocAElstein
10-04-2022, 02:14 AM
Continued from last post ( https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=19863&viewfull=1#post19863 )
Explanation of the two Match bits
Rem 1
Code:
Rem 1 try to match the name & Activity & Sub-activity
Dim arrD1() As Variant: Let arrD1() = WsD1.Evaluate("=A1:A25 & B1:B25 & C1:C25") ' This is a convenient way to get an array of the three things for all rows
Dim strSrch As String ': Let strSrch = Range("E2").Value & Range("F2").Value & Range("G2").Value ' This gives for example, "JohnA.1A.1.1"
Dim TgRw As Long: Let TgRw = Target.Row ' the changed target row
Let strSrch = Range("E" & TgRw & "").Value & Range("F" & TgRw & "").Value & Range("G" & TgRw & "").Value
Dim MtchRw As Long
Let MtchRw = Application.Match(strSrch, arrD1(), 0) ' this tries to match the correct row in Database1
This is fairly straight forward.
This is the array of name & Activity & Sub-activity
arrD1() =
NameActivitySub-activity
JohnA.1A.1.1
JohnA.1A.1.2
JohnA.2A.2.1
JohnA.2A.2.2
JohnA.3A.3.1
JohnA.3A.3.2
JohnA.4A.4.1
JohnA.4A.4.2
MarkA.1A.1.1
MarkA.1A.1.2
MarkA.2A.2.1
MarkA.2A.2.2
MarkA.3A.3.1
MarkA.3A.3.2
MarkA.4A.4.1
MarkA.4A.4.2
AnneA.1A.1.1
AnneA.1A.1.2
AnneA.2A.2.1
AnneA.2A.2.2
AnneA.3A.3.1
AnneA.3A.3.2
AnneA.4A.4.1
AnneA.4A.4.2
Now take for example the case of row 2 from worksheet database. I am looking to match this
JohnA.1A.1.1
So that is obviously 2 – ( Match tells me the position along in the array that it finds what it is looking for, the second position in this case is where it finds JohnA.1A.1.1 )
Rem 2 This is more tricky, and may not always work with different data. This initial solution may need to be re thought
This is the array of dates
arrDts() =
Name Activity Sub-activity 44866 44896 44927 44958 44986 45017 45047 45078
Now take for example from row 2, the date 30 November, 2022. Excel holds dates internally as numbers, and for the date 30 November, 2022 it has 44895.
I don’t have the number 44895 in my array. So this, Application.Match(DteV2, arrDts(), 0) , would give an error. It errors because it cannot find an exact match.
However we can use a 1 or -1 instead of the 0 in that final third argument in the Match - The syntax supports 3 different options, -1 0 1
If we choose 1 or -1 , then it will not error if it finds something close to what its looking for. The exact rules governing how that works are not so clear. I have a feeling Microsoft have some inconstant documentation in this.
For the case of using a 1 , we must have the numbers in the array in ascending order, which we have in the test data. I think then it tries to find the nearest smallest number.
Simple example to clarify:
In other words, if as a simple example, we had a 4 and a 9, in an array like this
{ 2 3 4 9 }
but we were lookig for a 8, then it would think that the matched value was 4, if we used a third argument of 1 in Match . So it would return us a 3 in that case as 4 is in position 3 along in the array.
In other words the 4 is the third number and its the nearest number to 8 that is smaller than 8. The number 9 is nearer, but that is a bigger number. (If we wanted that number 9 to get matched to 8, then I think the array must be in decending order, and we must use a -1 as the third argument in the Match
So...
Lets look again in detail at the test data and add some color highlighting to demo the results i get, which luckily are correct with the test data
The array: ( from Database1)
1
2
3
4
5
6
7
8
9
10
11
Name Activity Sub-activity
44866
44896
44927
44958
44986
45017
45047
45078
The 4 numbers I use from column D (from Database ) to get the results I want
44895
44895
44926
44985
If you follow the logic you can see that we will get the correct column numbers we want with the test data: We will get
4 4 5 7
But there are at least 3 issues to consider:
_1) This is relying on the date in column D in database being typically bigger than the corresponding date to be matched in Database1
_2) I am not sure how the Match always reacts to having a mixture of numbers and text in the array. It does not seem to cause a problem with the test data.
_3) The dates in Database1 must be typically in acending order. (I expect they probably willl be?)
( I added some extra stuff in the Database worksheet on the uploaded file to help show things a bit better )
DocAElstein
10-04-2022, 02:14 AM
https://i.postimg.cc/bNWqMYqT/1.jpg (https://postimages.org/)
https://i.postimg.cc/28Vz2LNy/2.jpg (https://postimages.org/)
https://i.postimg.cc/8kypRB3x/3.jpg (https://postimages.org/)
https://postimg.cc/TKSXsXV3
DocAElstein
10-04-2022, 02:14 AM
Some extra notes in support of this Thread post
https://excelfox.com/forum/showthread.php/2844-VBA-code-for-adding-data-from-a-sheet-to-another?p=19860&viewfull=1#post19860
I am using Match in two few places, and that is the main workings of the macro
Rem 1 - one gets the row number need for the output
Rem 2 – the other gets the column needed for the output
This is the test data given:
This is the requirement
.....
- the value from H2 cell (Database) to be added in D2 cell (Database1) because the name is John, the Activity is A.1, Sub-activity is A.1.1 and the Month is November 2022 (with yellow)
- the value from H5 cell (Database) to be added in G20 cell (Database1) because the name is Anne, the Activity is A.2, Sub-activity is A.2.1 and the Month is February 2023 (with gray)
.......and so on
Next post, some further explanations , in particular about what the Match bits are about
DocAElstein
10-04-2022, 02:14 AM
Simple example to clarify:
Continued from last post ( https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=19863&viewfull=1#post19863
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=21921&viewfull=1#post21921 )
Explanation of the two Match bits
Rem 1
Rem 1 try to match the name & Activity & Sub-activity
Dim arrD1() As Variant: Let arrD1() = WsD1.Evaluate("=A1:A25 & B1:B25 & C1:C25") ' This is a convenient way to get an array of the three things for all rows
Dim strSrch As String ': Let strSrch = Range("E2").Value & Range("F2").Value & Range("G2").Value ' This gives for example, "JohnA.1A.1.1"
Dim TgRw As Long: Let TgRw = Target.Row ' the changed target row
Let strSrch = Range("E" & TgRw & "").Value & Range("F" & TgRw & "").Value & Range("G" & TgRw & "").Value
Dim MtchRw As Long
Let MtchRw = Application.Match(strSrch, arrD1(), 0) ' this tries to match the correct row in Database1
This is fairly straight forward.
This is the array of name & Activity & Sub-activity
arrD1() =
NameActivitySub-activity
JohnA.1A.1.1
JohnA.1A.1.2
JohnA.2A.2.1
JohnA.2A.2.2
JohnA.3A.3.1
JohnA.3A.3.2
JohnA.4A.4.1
JohnA.4A.4.2
MarkA.1A.1.1
MarkA.1A.1.2
MarkA.2A.2.1
MarkA.2A.2.2
MarkA.3A.3.1
MarkA.3A.3.2
MarkA.4A.4.1
MarkA.4A.4.2
AnneA.1A.1.1
AnneA.1A.1.2
AnneA.2A.2.1
AnneA.2A.2.2
AnneA.3A.3.1
AnneA.3A.3.2
AnneA.4A.4.1
AnneA.4A.4.2
Now take for example the case of row 2 from worksheet database. I am looking to match this
John A.1 A.1.1
So that is obviously 2 – ( Match tells me the position along in the array that it finds what it is looking for, the second position in this case )
Rem 2 This is more tricky, and may not always work with different data. This initial solution may need to be re thought
This is the array of dates
arrDts() =
Name Activity Sub-activity 01-Nov-2022 44896 44927 44958 44986 45017 45047 45078
Now take for example from row 2, the date 30 November, 2022. Excel holds dates internally as numbers, and for the date 30 November, 2022 it has 44895.
I don’t have the number 44895 in my array. So this, Application.Match(DteV2, arrDts(), 0) , would give an error. It errors because it cannot find an exact match.
However we can use a 1 or -1 instead of the 0
If we do that it will not error if it finds something close to what its looking for. The exact rules governing how that works are not so clear. I have a feeling Microsoft have some inconstant documentation in this.
For the case of using a 1 , we must have the numbers its looking for in ascending order, which we have in the test data. I think then it tries to find the next smallest number.
Lets look again in detail at the test data and add some color highlighting to demo that
The array: ( from Database1)
1
2
3
4
5
6
7
8
9
10
11
NameActivitySub-activity
44866
44896
44927
44958
44986
45017
45047
45078
The 4 numbers I use from column D (from Database ) to get the results I want
44895
44895
44926
44985
If you follow the logic you can see that we will get the correct column numbers we want with the test data: We will get
4 4 5 7
But there are at least two issues to consider:
_1) This is relying on the date in column D in database being typically bigger than the corresponding date to be matched in Database1
_2) I am not sure how the Match always reacts to having a mixture of numbers and text in the array. It does not seem to cause a problem with the test data.
DocAElstein
10-06-2022, 02:33 PM
Second solution, Solution 2 for this thread
https://excelfox.com/forum/showthread.php/2815-Copy-data-from-multiple-rows-between-two-keyword-and-paste-the-data-in-row(s)-of-single-cell-in-sheet2
Sub ConsolidateLines_Solution2() ' https://excelfox.com/forum/showthread.php/2815-Copy-data-from-multiple-rows-between-two-keyword-and-paste-the-data-in-row(s)-of-single-cell-in-sheet2
Rem 0 worksheets data info
Dim Ws1 As Worksheet, Ws2 As Worksheet: Set Ws1 = ThisWorkbook.Worksheets.Item(1): Set Ws2 = ThisWorkbook.Worksheets.Item(2)
Dim Lr As Long: Let Lr = Ws1.Range("A" & Ws1.Rows.Count & "").End(xlUp).Row
Rem 3 Initial to get started, finding first start point of text we want
Dim RngStt As Range ' This will be the cell with the first Keywrod1
Set RngStt = Ws1.Range("A1:A" & Lr & "").Find(What:="Keywrod1", After:=Ws1.Range("A" & Lr & ""), LookIn:=xlValues, LookAt:=xlPart, Searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=True)
Rem 4 main text manipulation
'4a)
Do While Not RngStt Is Nothing ' This the main outer loop will terminate if we find no new first keyword #####
Dim RngStp As Range ' This willl be the cell with the next Keyword2
Set RngStp = Ws1.Range("A" & RngStt.Row + 1 & ":A" & Lr & "").Find(What:="Keyword2", After:=Ws1.Range("A" & RngStt.Row + 1 & ""), LookIn:=xlValues, LookAt:=xlPart, Searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=True)
If RngStp Is Nothing Then Exit Do ' This is for the case of if there is no Keyword2 after a found Keywrod1
'4b)
Dim Rw As Long
For Rw = RngStt.Row To RngStp.Row Step 1 ' We loop through the cells in between and including the cells with Keywrod1 and keyword2
Dim NewCelStr As String ' This is used to build the string for a new cell
Let NewCelStr = NewCelStr & Ws1.Range("A" & Rw & "").Value2 & vbLf ' Add the next cell text followed by a new line character
Next Rw
Let NewCelStr = Left(NewCelStr, Len(NewCelStr) - 1)
Dim Lr2 As Long: Let Lr2 = Ws2.Range("A" & Ws2.Rows.Count & "").End(xlUp).Row
Let Ws2.Range("A" & Lr2 + 1 & "").Value = NewCelStr
'4c(ii)
Let NewCelStr = ""
Set RngStt = Ws1.Range("A" & RngStp.Row & ":A" & Lr + 1 & "").Find(What:="Keywrod1", After:=Ws1.Range("A" & RngStp.Row + 1 & ""), LookIn:=xlValues, LookAt:=xlPart, Searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=True)
Loop ' While Not RngStt = Nothing ' ### Main outer loop terminates when main text manipulation is finished ##
Ws2.Columns(1).WrapText = False
End Sub
DocAElstein
10-06-2022, 02:33 PM
Second solution, Solution 2 for this thread
https://excelfox.com/forum/showthread.php/2815-Copy-data-from-multiple-rows-between-two-keyword-and-paste-the-data-in-row(s)-of-single-cell-in-sheet2
Sub ConsolidateLines_Solution2() ' https://excelfox.com/forum/showthread.php/2815-Copy-data-from-multiple-rows-between-two-keyword-and-paste-the-data-in-row(s)-of-single-cell-in-sheet2
Rem 0 worksheets data info
Dim Ws1 As Worksheet, Ws2 As Worksheet: Set Ws1 = ThisWorkbook.Worksheets.Item(1): Set Ws2 = ThisWorkbook.Worksheets.Item(2)
Dim Lr As Long: Let Lr = Ws1.Range("A" & Ws1.Rows.Count & "").End(xlUp).Row
Rem 3 Initial to get started, finding first start point of text we want
Dim RngStt As Range ' This will be the cell with the first Keywrod1
Set RngStt = Ws1.Range("A1:A" & Lr & "").Find(What:="Keywrod1", After:=Ws1.Range("A" & Lr & ""), LookIn:=xlValues, LookAt:=xlPart, Searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=True)
Rem 4 main text manipulation
'4a)
Do While Not RngStt Is Nothing ' This the main outer loop will terminate if we find no new first keyword #####
Dim RngStp As Range ' This willl be the cell with the next Keyword2
Set RngStp = Ws1.Range("A" & RngStt.Row + 1 & ":A" & Lr & "").Find(What:="Keyword2", After:=Ws1.Range("A" & RngStt.Row + 1 & ""), LookIn:=xlValues, LookAt:=xlPart, Searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=True)
If RngStp Is Nothing Then Exit Do ' This is for the case of if there is no Keyword2 after a found Keywrod1
'4b)
Dim Rw As Long
For Rw = RngStt.Row To RngStp.Row Step 1 ' We loop through the cells in between and including the cells with Keywrod1 and keyword2
Dim NewCelStr As String ' This is used to build the string for a new cell
Let NewCelStr = NewCelStr & Ws1.Range("A" & Rw & "").Value2 & vbLf ' Add the next cell text followed by a new line character
Next Rw
Let NewCelStr = Left(NewCelStr, Len(NewCelStr) - 1)
Dim Lr2 As Long: Let Lr2 = Ws2.Range("A" & Ws2.Rows.Count & "").End(xlUp).Row
Let Ws2.Range("A" & Lr2 + 1 & "").Value = NewCelStr
'4c(ii)
Let NewCelStr = ""
Set RngStt = Ws1.Range("A" & RngStp.Row & ":A" & Lr + 1 & "").Find(What:="Keywrod1", After:=Ws1.Range("A" & RngStp.Row + 1 & ""), LookIn:=xlValues, LookAt:=xlPart, Searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=True)
Loop ' While Not RngStt = Nothing ' ### Main outer loop terminates when main text manipulation is finished ##
Ws2.Columns(1).WrapText = False
End Sub
DocAElstein
11-08-2022, 02:40 PM
In support of this forum post
https://eileenslounge.com/viewtopic.php?f=30&t=38895
This is Hans final working Solution
' Hans https://eileenslounge.com/viewtopic.php?p=300746#p300746
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range, Pee As String
On Error GoTo Myerror
Let Application.EnableEvents = False
' If Not Intersect(Target, Columns(1)) Is Nothing Then
For Each Rng In Intersect(Target, Columns(1))
Let Pee = Replace(Replace(Evaluate("Proper(""" & Rng.Value & """)"), " ", ""), "-", "")
Select Case Pee
Case "A"
Let Rng.Value = "ABC"
Case "Aa"
Let Rng.Value = "XXD"
Case Else
Rng.ClearContents
End Select
Next Rng
' End If
Myerror:
Let Application.EnableEvents = True
End Sub
We can pretty this via Evaluate Range up in two main ways
_ The VBA Replace ideas can be replaced in the Evaluate by Excel spreadsheet SUBSTITUTE
_ The VBA Select Case ideas can be replaced by the Excel spreadsheet IF
The full coding example here follows approximately the Excel spreadsheet workings in the uploaded file. (In that file my workings are for the example range D11:D12 being copied and pasted into column 1, range A11:A12)
Note that in some steps the trick IF({1},___) was needed to get more than one result, but it was often found that in subsequent steps this could be removed. I expect this is because whatever phenomena is going on in that trick, goes on when we introduce steps involving IFs on multi cell ranges, so then the trick is redundant.
Private Sub Worksheet_Change(ByVal Target As Range) ' https://excelfox.com/forum/showthread.php/2834-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=19028&viewfull=1#post19028
Dim Pee As String ' , Rng As Range
On Error GoTo Myerror
Let Application.EnableEvents = False
If Not Intersect(Target, Columns(1)) Is Nothing Then
Dim varTest As Variant
Let varTest = Evaluate("=IF({1},PROPER(" & Target.Address & "))")
Let varTest = Evaluate("=IF({1},SUBSTITUTE(IF({1},PROPER(" & Target.Address & ")),"" "",""""))")
Let varTest = Evaluate("=IF({1},SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""))")
Let varTest = Evaluate("=IF({1},SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"",""""))")
Let varTest = Evaluate("=IF(IF({1},SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"",""""))=""A"",""ABC"",""x"")")
Let varTest = Evaluate("=IF(SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"","""")=""A"",""ABC"",""x"")")
Let varTest = Evaluate("=IF(SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"","""")=""A"",""ABC"",IF(SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"","""")=""Aa"",""XXD"",""""))")
'Let Target.Value2 = varTest
Let Target.Value2 = Evaluate("=IF(SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"","""")=""A"",""ABC"",IF(SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"","""")=""Aa"",""XXD"",""""))")
' For Each Rng In Intersect(Target, Columns(1))
' Let Pee = Replace(Replace(Evaluate("Proper(""" & Rng.Value & """)"), " ", ""), "-", "")
' Select Case Pee
' Case "A"
' Let Rng.Value = "ABC"
' Case "Aa"
' Let Rng.Value = "XXD"
' Case Else
' Rng.ClearContents
' End Select
' Next Rng
Else
' case not pasted in column 1
End If
Myerror:
Let Application.EnableEvents = True
End Sub
DocAElstein
11-08-2022, 02:40 PM
In support of this forum post
https://eileenslounge.com/viewtopic.php?f=30&t=38895
This is Hans final working Solution
' Hans https://eileenslounge.com/viewtopic.php?p=300746#p300746
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range, Pee As String
On Error GoTo Myerror
Let Application.EnableEvents = False
' If Not Intersect(Target, Columns(1)) Is Nothing Then
For Each Rng In Intersect(Target, Columns(1))
Let Pee = Replace(Replace(Evaluate("Proper(""" & Rng.Value & """)"), " ", ""), "-", "")
Select Case Pee
Case "A"
Let Rng.Value = "ABC"
Case "Aa"
Let Rng.Value = "XXD"
Case Else
Rng.ClearContents
End Select
Next Rng
' End If
Myerror:
Let Application.EnableEvents = True
End Sub
We can pretty this via Evaluate Range up in two main ways
_ The VBA Replace ideas can be replaced in the Evaluate by Excel spreadsheet SUBSTITUTE
_ The VBA Select Case ideas can be replaced by the Excel spreadsheet IF
The full coding example here follows approximately the Excel spreadsheet workings in the uploaded file. (In that file my workings are for the example range D11:D12 being copied and pasted into column 1, range A11:A12)
Note that in some steps the trick IF({1},___) was needed to get more than one result, but it was often found that in subsequent steps this could be removed. I expect this is because whatever phenomena is going on in that trick, goes on when we introduce steps involving IFs on multi cell ranges, so then the trick is redundant.
Private Sub Worksheet_Change(ByVal Target As Range) ' https://excelfox.com/forum/showthread.php/2834-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=19028&viewfull=1#post19028
Dim Pee As String ' , Rng As Range
On Error GoTo Myerror
Let Application.EnableEvents = False
If Not Intersect(Target, Columns(1)) Is Nothing Then
Dim varTest As Variant
Let varTest = Evaluate("=IF({1},PROPER(" & Target.Address & "))")
Let varTest = Evaluate("=IF({1},SUBSTITUTE(IF({1},PROPER(" & Target.Address & ")),"" "",""""))")
Let varTest = Evaluate("=IF({1},SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""))")
Let varTest = Evaluate("=IF({1},SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"",""""))")
Let varTest = Evaluate("=IF(IF({1},SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"",""""))=""A"",""ABC"",""x"")")
Let varTest = Evaluate("=IF(SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"","""")=""A"",""ABC"",""x"")")
Let varTest = Evaluate("=IF(SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"","""")=""A"",""ABC"",IF(SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"","""")=""Aa"",""XXD"",""""))")
'Let Target.Value2 = varTest
Let Target.Value2 = Evaluate("=IF(SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"","""")=""A"",""ABC"",IF(SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"","""")=""Aa"",""XXD"",""""))")
' For Each Rng In Intersect(Target, Columns(1))
' Let Pee = Replace(Replace(Evaluate("Proper(""" & Rng.Value & """)"), " ", ""), "-", "")
' Select Case Pee
' Case "A"
' Let Rng.Value = "ABC"
' Case "Aa"
' Let Rng.Value = "XXD"
' Case Else
' Rng.ClearContents
' End Select
' Next Rng
Else
' case not pasted in column 1
End If
Myerror:
Let Application.EnableEvents = True
End Sub
DocAElstein
07-17-2023, 01:41 PM
spare post for later
DocAElstein
07-17-2023, 01:41 PM
spare post for later
DocAElstein
07-17-2023, 01:41 PM
This is post https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=21923&viewfull=1#post21923
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=21923&viewfull=1#post21923
Page #58 https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page58
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page58
Some notes arising from discussions in this Thread
http://www.eileenslounge.com/viewtopic.php?f=30&t=39898&sid=6084746d589f95e0bf61085a6575decc
Edit Aug 2023: The general ideas are OK here, but we all overlooked, or maybe did not understand fully some basic stuff about how Range and range "values" in this basic code line work, Range2.Value = Range1.Value. Because of this some of the stuff in the final actual solution are redundant: - in particular, the solution of 1x and related stuff.
See
https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page10
https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page11
https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page12
Number stored as text, alignment of numeric values in cells
This problem/feature pops up from time to time.
https://i.postimg.cc/GpwT3Mzj/Number-stored-as-text.jpg
https://i.postimg.cc/18B3Jrkg/Number-stored-as-text.jpg (https://postimg.cc/18B3Jrkg) 5104
I have seen it so far in these sort of places/ things, such as text box contents are strings by definition (http://www.eileenslounge.com/viewtopic.php?p=309140#p309140) , …VBA enters text that is inherent to a TextBox. Every 'number' in a textBox is a string "1234". VBA has to convert those strings into long/integer, etc….
, and when pasting things out,
https://www.eileenslounge.com/viewtopic.php?p=269105#p269105 https://eileenslounge.com/viewtopic.php?p=272704#p272704
, but it’s not always consistent, - in the next example the 3 seems to go in as a number, but the 4 and 5 go in as …" Number stored as text"
https://i.postimg.cc/cCzwRfG1/Number-stored-as-text-inconsistancy.jpg
' https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=21923&viewfull=1#post21923
Sub Number_stored_as_text__alignment_of_numeric_values _in_cells() ' https://i.postimg.cc/cCzwRfG1/Number-stored-as-text-inconsistancy.jpg
Dim Ex As String
Let Ex = "3"
Let ActiveSheet.Range("A10").Value = Ex ' Puts in as number
Dim Exs(1 To 2) As String: Let Exs(1) = "4": Exs(2) = "5"
Let ActiveSheet.Range("A11:B11").Value = Exs()
End Sub
https://i.postimg.cc/cCzwRfG1/Number-stored-as-text-inconsistancy.jpg (https://postimages.org/)
DocAElstein
07-17-2023, 01:41 PM
Number stored as text, alignment of numeric values in cells
Evaluate Range correction
The problem from the last post lends itself nicely to the Evaluate Range ideas. As often, this idea is based on a simple mathematical formula, which is itself one of a few ways in Excel and VBA we have a few ways to coerce a text to a number:
In Excel and VBA we have a few ways to coerce or "Methods to convert", http://www.eileenslounge.com/viewtopic.php?p=309140#p309140
One simple way is to multiply by 1.
Edit Aug 2023: The general ideas are OK here, but we all overlooked, or maybe did not understand fully some basic stuff about how Range and range "values" in this basic code line work, Range2.Value = Range1.Value. Because of this some of the stuff in the final actual solution are redundant: - in particular, the solution of 1x and related stuff.
See
https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page10
https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page11
https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page12
As ever with these Evaluate Range solutions, we start with a single cell formula which works in Excel.
Take the screenshot example from the last post. In C11 this appears to work, =1*A11
_____ Workbook: Number stored as text, alignment of numeric values in cells.xls ( Using Excel 2013 32 bit )
Row\ColABC
103
1145=1*A11
12
Worksheet: Sheet1
https://i.postimg.cc/prJFZt2s/1xA11.jpg
https://i.postimg.cc/prJFZt2s/1xA11.jpg (https://postimages.org/) 5105
What that simple formula appears to do is to make the 4 in cell A11 be written in cell C11 a true number, and so we effectively get rid of that warning of the form , "Number stored as Text"
Now the Evaluate Range bit.
Evaluate Range ideas are often a neat alternative to looping in VBA
Staying with Excel initially. (**Note: This explanation may not suit so well for an Excel version with the Spill/Dynamic arrays stuff, (currently from about version 365).)
In Excel, like in a lot of computer stuff, what we look at, or get as output to see, is based on something
chucking out from left to right
,then returning to the left, ( sometimes referred to as "invisible" character like Carriage Return vbCr )
, and then going to a new line/row, ( sometimes referred to as "invisible" character like LineFeed vbLf )
, then starting again until we get a 2 dimensional picture we as humans understand. In some cases this means that similar calculations may be done by default over an extended range, but normally we don’t see that as in Excel we look at doing stuff in one of excel boxes/cells. Somehow Excel will be wired to show a single value in a cell in a typical formula such as our =1*A11
Whether by design or accident, right from the start of when Excel came about, we can get some interesting results if we replace a single cell reference by a multiple one.
For example, in C11, write =1*A11:B11 instead, so as to maybe see if we can somehow do our basic formula for cells A11 and B11 at the same time.
But, try that and it will error**. Never mind. Let’s keep experimenting.
https://i.postimg.cc/k5CmNLgp/1x-A11-B11.jpg
https://i.postimg.cc/zBXY6WWw/1xA11B11.jpg
(** For Excel 365 it may not error, and I prefer not to consider yet what is happening there)
Type 1 CSE entry
There may be some reason such as extra overheads for Excel to show the same calculation for both cells, resulting in perhaps a deliberate prevention of the thing working, but my guess is that it does work without too much effort. Often we talk about Type 1 CSE entry, or CSE entry in general, as a way to tell Excel that you would like to take advantage of the possibility to do the calculation for a range other than a single cell.
To get the first inclination about what I am talking about, do this: do the same thing again, in C11, write =1*A11:B11 , but don’t hit Enter yet. Instead, hold keys Ctrl+Shift and then hit Enter
We don’t error anymore. But we still only see one value. https://i.postimg.cc/m2v5xMCx/1x-A11-B11-CSE1.jpg
If you apply a bit of lateral thinning to what we said earlier about how computer things work , ( ……chucking out from left to right , returning to the left and gong to a new line/row, then starting again ) , a good guess might be that in our example the other calculated value might be somewhere close to the right. That takes us nicely on to the next section, and how that relates to our example
Type 2 CSE entry
CSE generally seems to tell Excel to do multiple cell calculations, at least that is what we suggested. (We talk sometimes about "array calculations", but this may be strictly in mathematical definitions a bit incorrect)
But we generally write things in a cell, and generally for simple formulas we would expect a result in a cell.
But let's try it a bit differently, bearing in mind our example. So, start again, but before you type =1*A11:B11, first select the two cells, C11 and D11. Then after you type that, do the CSE entry again, not a simple Enter
https://i.postimg.cc/m2w2rQN9/1x-A11-B11-CSE2.jpg
Bingo!
https://i.postimg.cc/m2RgRdMR/1x-A11-B11-CSE2-Bingo.jpg
https://i.postimg.cc/z3trFF0P/1x-A11-B11-CSE2-Bingo.jpg (https://postimg.cc/z3trFF0P) 5106
Evaluate Range Solution as alternative to VBA Looping
So far we have just considered an Excel solution. That background was necessary to understand the Evaluate Range type Solution as alternative to VBA Looping
In VBA, a conventional way to do multi cell calculations would be to Loop. It loops, in other words does a similar codung a few times. It would need to do it twice, https://i.postimg.cc/Wb8ZRJM7/Loop-in-values-in-row-12-column-C-and-D-from-column-A-and-B.jpg , in our example:
Sub LoopItTwice() ' https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=21924&viewfull=1#post21924
Dim Nmbr As Long
For Nmbr = 1 To 2 Step 1
Let ActiveSheet.Cells.Item(12, Nmbr + 2).Value = ActiveSheet.Cells.Item(11, Nmbr).Value ' Always uses row 12 , done twice, first for column 3 value = column 1 value and then column 4 value = column 2
Next Nmbr
End Sub
We have just discussed that the CSE stuff in Excel gives us a way to do it in one go. Let’s investigate if we can do something like that in VBA
Do Excel stuff in VBA
In VBA there is a Evaluate("__") function. In simple terms, to a first approximation, we can put Excel formulas inside the quotes, here
Evaluate("here")
, and the result is returned, similar to what would be returned in a cell with that formula in it.
Exactly what may be "returned" (chucked at us from Evaluate("__") ) , may be many things, depending on the exact formula, so it makes sense that the thing is wired to return a Variant type, so that can hold whatever actual type comes from the evaluation. So something like this sort of form would be done in VBA
Dim Var As Variant
_Let Var = Evaluate("=A11:B11*1")
If you put a Stop statement (or alternatively click in the left margin to get a brown circle which works the same), then run the following full macro, then while it is paused, (or before you start) , highlight Var , hold key Shift and then hit key F9, to put a watch on that variable, then you can see the results.
https://i.postimg.cc/vmPf13Cx/Put-a-watch-on-Var.jpg
https://i.postimg.cc/mDtM77GX/Put-a-watch-on-Var.jpg
Sub RangeEvaluate()
Dim Var As Variant
Let Var = Evaluate("=A11:B11*1")
Stop ' If you put a Stop statement (or alternatively click in the left margin to get a brown circle which works the same), then run the following full macro, then while it is paused, (or before you start) , highlight Var , hold key Shift and then hit key F9, to put a watch on that variable, then you can see the results.
'https://i.postimg.cc/vmPf13Cx/Put-a-watch-on-Var.jpg
'https://i.postimg.cc/mDtM77GX/Put-a-watch-on-Var.jpg
End Sub
https://i.postimg.cc/9Mb931YQ/Put-a-watch-on-Var.jpg
https://i.postimg.cc/9Mb931YQ/Put-a-watch-on-Var.jpg (https://postimages.org/)
Occasionally, the Evaluate(" ") does not "return" more than one result in formulas involving multi cell ranges, but this appears to be a separate issue to the need for CSE measures. Often we can do empirically derived tricks to overcome such problems.
But in many cases the Evaluate(" ") does returns the same results immediately that are only returned in a spreadsheet via the CSE way discussed. It would appear that principally the Evaluate(" ") is not restricted by the single cell , or need for CSE entry issues as in the spreadsheet. Perhaps this is because in use, Evaluate(" ") is not tied in some way to a particular spreadsheet format to show its output. There appears to be a lot of uncertainty ad empirically derived solutions and tricks in Evaluate Range
So, we have our result, or a way to get it chucked at us , "returned" , by using an Excel spreadsheet formula from within VBA
So what do we do with it/ how do we get it in a cell, or more specifically in our example, how do we get it in cells,
……. Next post
DocAElstein
07-20-2023, 05:27 PM
From last post, to recap a bit……
Do Excel stuff in VBA
In VBA there is a Evaluate("__") function. In simple terms, to a first approximation, we can put Excel formulas inside the quotes, here
Evaluate("here")
, and the result is returned, similar to what would be returned in a cell with that formula in it.
Exactly what may be "returned" (chucked at us from Evaluate("__") ) , may be many things, depending on the exact formula, so it makes sense that the thing is wired to return a Variant type, so that can hold whatever actual type comes from the evaluation. So something like this sort of form would be done in VBA
Dim Var As Variant
_Let Var = Evaluate("=A11:B11*1")
If you put a Stop statement (or alternatively click in the left margin to get a brown circle which works the same), then run the following full macro, then while it is paused, (or before you start) , highlight Var , hold key Shift and then hit key F9, to put a watch on that variable, then you can see the results.
https://i.postimg.cc/vmPf13Cx/Put-a-watch-on-Var.jpg
https://i.postimg.cc/mDtM77GX/Put-a-watch-on-Var.jpg
Sub RangeEvaluate()
Dim Var As Variant
Let Var = Evaluate("=A11:B11*1")
Stop ' If you put a Stop statement (or alternatively click in the left margin to get a brown circle which works the same), then run the following full macro, then while it is paused, (or before you start) , highlight Var , hold key Shift and then hit key F9, to put a watch on that variable, then you can see the results.
'https://i.postimg.cc/vmPf13Cx/Put-a-watch-on-Var.jpg
'https://i.postimg.cc/mDtM77GX/Put-a-watch-on-Var.jpg
End Sub
https://i.postimg.cc/9Mb931YQ/Put-a-watch-on-Var.jpg
https://i.postimg.cc/9Mb931YQ/Put-a-watch-on-Var.jpg (https://postimages.org/)
So, we have our result, or a way to get it chucked at us , "returned" , by using an Excel spreadsheet formula from within VBA
So what do we do with it/ how do we get it in a cell, or more specifically in our example, how do we get it in cells
Simple application of Evaluate("=A11:B11*1") type solutions
( Put what is chucked at us, ("returned") into cells )
Conveniently, Excel VBA allows a “field” or array of values, in other words a “square” or grid full of values to be applied directly to a rectangular range, pseudo code examples:
Simple application of Evaluate("=A11:B11*1") type solutions
Conveniently, Excel VBA allows a “field” or array of values, in other words a “square” or grid full of values to be applied directly to a rectangular range, pseudo code examples:
Range(“A1:B2”) values = { a b
_________________--__________c d }
Range(“A1:C1”) values = { x y z }
Range(“D1:E1”) values = { 4, 5 }
The right hand side of that last equation could be the array or field of values which was returned by our example, Evaluate("=A11:B11*1") . An actual working syntax to do in VBA what we did via CSE techniques previously would be
Range("C11:D11").Value = Evaluate("=A11:B11*1")
VBA coding “ works backwards “ , doing the right hand side first, so if we wanted to replace the original range with the values without the Number stored as text thing, then this would work
Range("A11:B11").Value = Evaluate("=A11:B11*1")
At this point we note that this basic coding layout can be written in a few different forms. In particular, we have great flexibility on the right hand side by virtue of the fact that the Evaluate takes a string argument. We are free to build up strings in VBA as we choose. They can be built up from hard coded text, as we currently have, or we can also include VBA things which would be converted at run time to what they evaluate to. For example, Range("A11:B11").Address returns $A$11:$B$11 , which for our purposes, in spreadsheet syntax, as used in a spreadsheet cell, has the same effect as A11:B11. So that last code line could be written
Range("A11:B11").Value = Evaluate("=" & Range("A11:B11").Address & "*1")
The last two code lines are effectively replacing a range which might have the Number stored as text thing showing to a range without that showing. In other words, it removes the Number stored as text thing.
We are free to replace the range Range("A11:B11") with any range we choose.
_ It could be some variable defined as a range like this
Dim Rng As Range
Set Rng = Range("A11:B11")
Let Rng.Value = Evaluate("=" & Rng.Address & "*1")
_ Similarly, we could make some selection in the spreadsheet, and then run the macro on this range using
Let Selection.Value = Evaluate("=" & Selection.Address & "*1")
This last macro is often the most convenient, but bear in mind that it will replace the original range, and things done by VBA can’t be undone. Best would be to test first by pasting a copy in a spare range. For example, if you have data up to column F, then this would put the test range to the side of it.
Selection.Offset(0, 6).Value = Evaluate("=" & Selection.Address & "*1")
(As often in VBA, the Offset works on the top left, shifting the whole range with it. In the inner workings of Excel VBA, things are often anchored or referenced to the top left)
In a few posts time we some simple variations of the Evaluate range way to remove the Number stored as text thing issue, specifically we are making the last few coding version less susceptible to problems / more workable on different data types
But first we will recap and discuss a useful typical format / versions of our final coding for test and developments
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
https://www.youtube.com/watch?v=jdPeMPT98QU (https://www.youtube.com/watch?v=jdPeMPT98QU)
https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg (https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5 (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl )
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2 (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2)
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
DocAElstein
07-20-2023, 07:15 PM
Number stored as text, alignment of numeric values in cells
Improved/ Extended Evaluate Range solution. Recap General Purpose solution
In a few posts time we will discusses extending the last solution to overcome a couple of problems that may occur with certain types of range data, specifically, if there may be empty cells or cells with real text in it. In this and the following 2 posts we will recap and come up with a general purpose solution to then go on and modify.
General all purpose version of our final Evaluate Range solution Range variable, Rng
Let us both standardise and recap on a good general purpose version of our Evaluate Range solution, with emphasis on learning and test and developing
Range variable, Rng
It’s probably more often than not a good idea to use a variable for our main data range. In technical terms we might re say that, as a variable for our main Range object. Using a variable for things is often a good idea, and particular a good idea for a range object, since Excel and Excel is all about boxes and manipulating them, and in VBA in particular, we have a lot of useful built in things like Methods, Properties, and the such, that we can use on them/ with them, in particular the range object since that is in particular to do with the box, and boxes structure that Excel is all about.
So for some test range, such as A1:F7,
https://i.postimg.cc/nctNH0WJ/Range-A1-F7.jpg
5113 https://i.postimg.cc/nM032YZR/Range-A1-F7.jpg (https://postimg.cc/nM032YZR)
, then somewhere towards the start of any macro we might have something like this
Dim Rng As Range
_Set Rng = Worksheets.Item("Sheet1").Range("A1:F7")
You can often get away without the Worksheets.Item("Sheet1"). , if you know what you are doing and are sure that Excel will guess correctly which worksheet you are wanting to refer to, but often in a final coding, Excel may guess wrong, so more fully referencing a range is a good habit to get into.
We may as well, from the start of our coding get fully into such good habits, and use a variable for the worksheet also
Dim Ws1 As Worksheet
_Set Ws1 = ThisWorkbook.Worksheets.Item("Sheet1")
Dim Rng As Range
_Set Rng = Ws1.Range("A1:F7")
This Rng is referring to the test data range……._
DocAElstein
07-20-2023, 10:16 PM
General all purpose version of our final Evaluate Range solution Range variable, The left hand side, LHS, of a general purpose code line.
The left hand side, LHS, of a general purpose code line.
_....... This Rng is referring to the test data range.
We want to modify/ correct that, so up until now that was the thing on the LHS.
But, it is convenient in test and development not to replace the original range, but perhaps rather, if you have space, put the output from the coding calculations somewhere alongside. That way if something goes wrong, you don’t have to try and find the original data in order to try again. For example this would be the LHS to place the result alongside to the right. _Let Rng.Offset(0, Rng.Columns.Count).Value =
That is a good choice to use as we are sure to place to the right, since we offset the output a number of column equal to the number of columns that the range has. Personally, I might do this
_Let Rng.Offset(0, Rng.Columns.Count + 1).Value =
, since an extra empty column in between can have later advantages.
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
https://www.youtube.com/watch?v=jdPeMPT98QU (https://www.youtube.com/watch?v=jdPeMPT98QU)
https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg (https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5 (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl )
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2 (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2)
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
DocAElstein
07-22-2023, 01:39 PM
General all purpose version of our final Evaluate Range solution Range variable, The right hand side, RHS, of a general purpose code line.
The right hand side, RHS, of a general purpose code line.
As far as the RHS of the equation goes, that is our Evaluate Range bit, and that will want to be referencing our test data, which is simply Rng, as far as VBA is concerned – that is the whole point about using a variable,
However we need to remember that we need Excel spreadsheet syntax inside the Evaluate("____") . For simple hardcoding that is =A1:F7 , just as we would write it in the cell. We could also use fixed cell referencing, =$A$1:$F$7 , as for our purposes it would work just the same. So they are OK for us.
For our general purpose standardised solution we want to make it dynamic, in other words we don’t want to hard code to a specific range, but would like to be able to get the Excel syntax from our VBA Rng variable, regardless of what the actual range might be at any time in our test and development
The VBA Range.Address Property (Excel) is useful here ( https://learn.microsoft.com/en-us/office/vba/api/excel.range.address )
The VBA Range.Address Property
The VBA Range.Address Property has a few arguments, here is the first 4
RowAbsolute:= default value is True, which gives the absolute $ type references $A$1:$F$7 , which are OK for us
ColumnAbsolute:= default value is True, which gives the absolute $ type references $A$1:$F$7 , which are OK for us
ReferenceStyle:= default gives us the default Excel spreadsheet column Letter and row Number referencing ( in other words A1, B$3 etc., rather than RC[-1] stuff ) which we want
External:= This could do with a bit of discussion:
If we set this to True, which is not the default we are arguably doing things a bit better since we are ensuring we refer to the correct worksheet, (and the correct workbook).
https://i.postimg.cc/TYCc8Fc4/Range-A1-F7-Address-External-True.jpg
https://i.postimg.cc/zGvFq7tX/Range-A1-F7-Address-External-True.jpg
https://i.postimg.cc/jS1Q2fm6/Range-Address-External-A1-F7-Address-External-True.jpg
https://i.postimg.cc/LXmjVN2z/Range-A1-F7-Address-External-True-Debug-Print-in-Immediate-Window.jpg
And/ but note a couple of things,
_Although the full syntax is allowed in the worksheet, ( https://i.postimg.cc/jS78Gv9p/Full-external-referrence-acccepted-in-Worksheet.jpg
https://i.postimg.cc/fTF221H7/Full-Worksheet-referrence-acccepted-in-Worksheet.jpg ) , it is not necessary in the worksheet, since the formula is in the worksheets, so the extra syntax is redundant
_Evaluate(" ") is not necessarily always linked to a worksheet, so the full reference could be a good idea.
However, relying on the defaults for the VBA Range.Address Property on the RHS helps us to simplify the RHS equation, so we will not do this, but instead note*** we can do this better, more fuller referencing in another way, Later***.
So the point of this post was to produce a general purpose Evaluate Range type solution to then go on and extend, and this last bit was considering the RHS
Hard coded had in it of this form for the data range, , A1:F7 , and we noted that this will do as well, $A$1:$F$7
We can get that by relying on the defaults in the The VBA Range.Address Property and so can , in VBA get something like that from Rng.
https://i.postimg.cc/5jdHjw5R/Range-A1-F7-Address-default-Properties.jpg
5114 https://i.postimg.cc/sGmfNGNY/Range-A1-F7-Address-default-Properties.jpg (https://postimg.cc/sGmfNGNY)
Sub DevelopmentTest() ' https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=21964&viewfull=1#post21964
Dim Ws1 As Worksheet
Set Ws1 = ThisWorkbook.Worksheets.Item("Sheet1")
Dim Rng As Range
Set Rng = Ws1.Range("A1:F7")
Debug.Print Rng.Address ' gives im Immediate Window $A$1:$F$7 ( After running macro, hit keys Ctrl+g from VB Editor to get Immediate window( Direktbereich in German), in which this code line should have put the value of Rng.Address(External:=True) something like this sort of form '[Number stored as text, alignment of numeric values in cells.xls]Sheet1'!$A$1:$F$7
Debug.Print Rng.Address(External:=True) ' After running macro, hit keys Ctrl+g from VB Editor to get Immediate window( Direktbereich in German), in which this code line should have put the value of Rng.Address(External:=True) something like this sort of form '[Number stored as text, alignment of numeric values in cells.xls]Sheet1'!$A$1:$F$7
End Sub
We want this result , $A$1:$F$7, to be available inside Evaluate(" ")
Possibly one of the most useful things about Evaluate(" ") is that it takes a string of text, in other words, what goes in between the " ") is in the syntax of what you would put in a worksheet cell. In VBA we are free to use actual hardcoded text and/ or VBA things to build up that text within VBA, following the usual VBA syntax rules of having text and other things joined by a __&___ Actual hard coded text, as you want in the worksheet formula goes inside a " ") pair. VBA things in VBA syntax should not be inside a " ") pair, as then VBA will first “do them” , and as long as they return a text string, the _&__ or _&_s will finally result in one final string.
If we are only using a single VBA thing, and nothing else, then " ") no pair is required, since the use of a " ")/FONT] pair in VBA coding tells VBA that it is being given actual hardcoded text. When the VBA thing is done, it returns a string, or text, which any _&__s would join to other text. What I am trying to say here is that to get the text $A$1:$F$7 inside Evaluate(" "), then this would do
Evaluate(Rng.Address)
As far as what VBA “sees”, that is the same as if you were to write this
Evaluate("$A$1:$F$7")
A few oddities
It is not clear why you do not need a leading [FONT=Courier New]=, but it will accept it, and these return the same as if the = was ommited.
Evaluate("=" & Rng.Address)
Evaluate("=$A$1:$F$7")
My guess is that VBA assumes you have it/ effectively adds it by default if you miss it out. (Perhaps we should note here that we cannot write a simple text in Evaluate("__") as we would in a cell. This would error Evaluate("xyz")
Evaluate("__") will however take a number. This would not error Evaluate("6")
So there is not a perfect correlation between what we put in Evaluate("___" ) and what we put in a cell.
Perhaps Evaluate("__") is associated with all things in a cell to do with numbers and calculations. Simple text writing in a cell is something extra for a worksheet and slightly outside what Excel is about. Excel is mainly about boxes with numbers in it, and calculations on them
Almost finished, back to the main issue
Personally, even if I am just using a VBA thing in the Evaluate("__"), I prefer to include both leading and trailing " " bits, like this
Evaluate("=" & Rng.Address & "")
Doing that has the advantage, for example, of making it more easy to build up a final string.
In our case, for example, we finally want =1*A1:F7 ( or =1*$A$1:$F$7 will do just as well )
I think it is fairly easy at this stage to see what we finally need on the RHS:
__________________Evaluate("=1*" & Rng.Address & "")
One final Useful Tip
A final useful Tip, that helps to make sure you halve the correct syntax inside the Evaluate("___ ")
If we try to be very precise, I think we can say that it is the thing inside the brackets in this, Evaluate(___ ) , that takes the syntax of a string. Now, bearing that in mind, along with the fact that in VBA coding an enclosing " " needs to be used to tell VBA that you are giving it text, we can either hard code like this
_________________________ = Evaluate("=A1")
, or use a string variable like this
Dim strEval As String
_ Let strEval = "=A1"
_________________________ = Evaluate(strEval)
( We must always remember the strange exceptional difference between what we can put in a cell and what we can put in = Evaluate("___") – Unlike in a cell, it will not take a simple text , in Evaluate("___") it must be a formula or number. )
It is very easy to get text and text shown in enclosing "s mixed up, since often in various writings an enclosing " " pair may or may not be used. As an approximate general rule we can often say that
_ (i) a medium predominantly used for displaying normal human readable basic written text, will not display the text in enclosing "s.
_ (ii) a medium which uses text but may not predominantly be used to display normal human readable basic written text, or a medium not used to display some specific normal human readable basic written text that comes from somewhere else, (for example, when quoting some text from somewhere else) will enclose the normal human readable basic written text in enclosing "s.
VBA is like (ii) . It needs to be or otherwise coding might get mistaken for simple normal human readable basic written text
The Immediate Window, is like (i) , because its primary use is to allow us to see the single value in a simple variable, or one element of an array.
OK, now the Tip
What is inside the " " here, Evaluate(" ") or the actual text in our variable strEval is what we would manually put in an Excel cell.
So if we use
Debug.Print strEval
, then what is seen in the Immediate window should have the correct syntax for what we would manually write in an Excel cell. If it is not then, Evaluate(strEval) will most likely error.
Using our previous example,
Sub CheckSyntaxForEvalString()
Dim Ws1 As Worksheet, Rng As Range
Set Ws1 = ThisWorkbook.Worksheets.Item("Sheet1")
Set Rng = Ws1.Range("A1:F7")
Dim strEval As String
Let strEval = "=1*" & Rng.Address & ""
Debug.Print strEval
End Sub
, we can clearly see that we have the correct syntax
https://i.postimg.cc/GpLGBTPQ/Debug-Print-str-Eval.jpg
5115 https://i.postimg.cc/G4fHV258/Debug-Print-str-Eval.jpg (https://postimg.cc/G4fHV258)
https://i.postimg.cc/GpLGBTPQ/Debug-Print-str-Eval.jpg (https://postimages.org/)
DocAElstein
07-22-2023, 01:40 PM
Number stored as text, alignment of numeric values in cells
Improved/ Extended Evaluate Range solution.
Based on all the posts so far on this page, we have got this far,
Sub Number_stored_as_text() ' https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=21967&viewfull=1#post21967
Dim Ws1 As Worksheet, Rng As Range
Set Ws1 = ThisWorkbook.Worksheets.Item("Sheet1")
Set Rng = Ws1.Range("A1:F7")
Dim strEval As String
Let strEval = "=1*" & Rng.Address & ""
Debug.Print strEval ' gives =1*$A$1:$F$7
Let Rng.Offset(0, Rng.Columns.Count + 1).Value = Evaluate(strEval)
End Sub
This is our test data, https://i.postimg.cc/KvhPVN44/Test-Data.jpg
https://i.postimg.cc/8PkRNCBV/Test-Data.jpg
5116https://i.postimg.cc/0rZKK7Yq/Test-Data.jpg (https://postimg.cc/0rZKK7Yq) https://i.postimg.cc/8PkRNCBV/Test-Data.jpg (https://postimages.org/)
_____ Workbook: Number stored as text, alignment of numeric values in cells.xls ( Using Excel 2013 32 bit )
Row\ColABCDEF
1PageLetterordernrQuantCostCost/quant
21122334455
31122334455
455443322110,5
555443322110,5
644Y234573460,71,7568741
755X223434160,74,60458453
Worksheet: Sheet1
This is the result after running the macro
_____ Workbook: Number stored as text, alignment of numeric values in cells.xls ( Using Excel 2013 32 bit )
Row\ColABCDEFGHIJKLM
1PageLetterordernrQuantCostCost/quant#WERT!#WERT!#WERT!#WERT!#WERT!#WERT!
2112233445511223344550
3112233445511223344550
455443322110,555443322110,5
555443322110,555443322110,5
644Y234573460,71,756874144#WERT!234573460,71,75687 4
755X223434160,74,6045845355#WERT!223434160,74,6045 85
Worksheet: Sheet1
https://i.postimg.cc/v8V73jYp/Test-Data-After.jpg (https://postimages.org/)
Oh bollox, a couple of problems
We see a couple of problems. An empty cell comes out as a 0 in the output, and text in any cell results in an error in the output.
In the next post, we look at overcoming these two problems
DocAElstein
07-22-2023, 05:55 PM
Number stored as text, alignment of numeric values in cells
Improved/ Extended Evaluate Range solution.
Problem 1 text produces error in output.
Is it text or is it a number. Not as simple a question as you might think.
Initially a Layman might expect this problem, since multiplying a text by a number sounds dodgy. But we never know exactly how the makers of Excel program things, so we might just as well have thought it might return one of the text, or just recognise the text and so decide to do nothing but return it. But it appears that it errors.
So what to do.
The point of using these Evaluate Range ideas is to get a simple single code line that appears to do all in one go what more conventionally would be done in classic looping techniques. So initial we would usually see if we can solve the problem in the spreadsheet formula / expression.
We need something to help us distinguish between text and numbers, bearing in mind we have the complication of some numbers held as text. We want something that will distinguish between what we see as numbers and text, regardless of how Excel is holding anything we see as a number.
We have an ISTEXT and ISNUMBER function in Excel.
If we do some simple testing on the test data range we find that the ISTEXT will return true for our cells with a number stored as text, but not for cells with a simple number. So that looks perhaps less useful to us. Initially I did not expect the ISNUMBER to be useful either, since the Microsoft documentation say something like ISNUMBER("19") will return False.
Initial experiments confirm this. Take a small sample of our test range, A6:B7
https://i.postimg.cc/jdBJLVDM/Range-A6-B7.jpg
5117https://i.postimg.cc/8jBC00Bv/Range-A6-B7.jpg (https://postimages.org/)
https://i.postimg.cc/jdBJLVDM/Range-A6-B7.jpg (https://postimages.org/)
DocAElstein
07-22-2023, 07:24 PM
Stop
Time to think again, before going further
Aug 2023: The general ideas were/ are OK here so far, but we all overlooked, or maybe did not understand fully some basic stuff about how Range and range "values" in this basic code line work, Range2.Value = Range1.Value. Because of this some of the stuff in the final actual solution are redundant: - in particular, the solution of 1x and related stuff.
See
https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page10
https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page11
https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page12
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
https://www.youtube.com/watch?v=jdPeMPT98QU (https://www.youtube.com/watch?v=jdPeMPT98QU)
https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg (https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5 (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl )
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2 (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2)
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
DocAElstein
08-01-2023, 03:57 PM
This post https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page2#post21998 Post #15
Some notes on support of these Threads and posts
https://eileenslounge.com/viewtopic.php?p=309151#p309151
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=22078&viewfull=1#post22078
Why did we Stop after the last few posts
We need to start again with the Evaluate(" "), that is to say the RHS _____ = Evaluate(" ") thing , and consider at the same time the RHS range thing _____ = Range(" ")
_ RHS _____ = Evaluate(" "), and RHS range object assignment thing _____ = Range(" ")
There seems to be some similarity in things they do
What is Evaluate(" "), with emphasis with what goes on in a spreadsheet cell
(Or what is going on in a cell after typing = ). I think maybe that when in a [cell] you write = , it can be considered as similar to this pseudo coding in VBA
[write in Cell] = Evaluate("What you put in the cell after the = ")
In simple terms, to a first approximation, Evaluate(" ") allows you to do in VBA within the " " what you do after the = in a cell.
(So perhaps its understandable that
_ you can omit the = within the " " in Evaluate(" "), although it is accepted syntaxly: Perhaps it is then just redundant* since Evaluate is about doing what is after the = in an Excel cell
_ You can’t just put simple text in evaluate, as you can with a cell, you need to do it as
___ ' 1a)(i) you can additionally give text in a cell, as part of a formula, ( Example In cell ="Text in Formula in Excel"
___ ' 1a)(ii) or carefully tell the Evaluate(" ") to take/Evaluate a literal string, rather than Evaluate the string as if it were something after a = in a cell, which is what Evaluate is about*
Range objects in spreadsheets and Excel worksheet functions returning a range object. )
When we use cells in a spreadsheet, we may appear to be using simple text, numbers and formulas. Often we may have a formula which finally gives us a number. In some cases we may indeed get a simple number result. Within a formula, cell references may appear to just get the number or text from a cell, but in fact Excel manipulates range objects. Once you have some basic VBA knowledge, this will perhaps make sense, especially if you are aware that it is something similar to VBA that makes what you see work: Think of Excel spreadsheets as lots of functions that trigger when you change things in cells.
Bearing this in mind, it is perhaps reasonable to expect that things like Evaluate("=A1") , Evaluate("A1:B2") etc. in VBA might return a range object. Indeed they do!
You must make sure to do a Set them to a range object on the LHS,
[color=Blue]Set Rng = Evaluate("=A1")
If you Let them to a Variant variable, (or for the case of a single cell, any suiting variable type), then VBA seems to be written to oblige and give an array of values (or a value for a single cell)
Sub RangeEvaluate() ' https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=22078&viewfull=1#post22078
Rem 0
Dim Ws As Worksheet
Set Ws = ThisWorkbook.Worksheets("RangeValuevalues")
Ws.Range("B1").Clear
Rem 1 write in Cell, a value and something else - I want to do this cell writing from VBA ="Text in Formula in Excel"
' 1a)(i)Excel value is = " Text in Formula in Excel " in other words a formula
Let Ws.Range("B1") = "=" & """" & "Text in Formula in Excel" & """" ' This is like manually writing ="Text in Formula in Excel" in a cell, a formula or like saying is to be evaluated "Text in Formula in Excel"
Ws.Range("B1") = "=""Text in Formula in Excel""" ' simplid Alternative - take out all " & " since in VBA they stop text" and lin& to "start of another text
Ws.Range("B1").Clear ' is " = " " Text in Formula in Excel " " "
Let Ws.Range("B1") = Evaluate("=" & """" & "=" & """" & """" & "Text in Formula in Excel" & """" & """" & """"): Debug.Print "=" & """" & "=" & """" & """" & "Text in Formula in Excel" & """" & """" & """" ' It is always worth doing this to see what text Evaliate(" ") actually sees inside the " " , in this case it gives in Immediate Window ="=""Text in Formula in Excel"""
Ws.Range("B1") = Evaluate("=""=""""Text in Formula in Excel""""""") ' Alternative https://i.postimg.cc/W3n3Q2ST/Remove-some-in-VBA-Quote-Ambersand-Quote.jpg
' 1a)(ii) use Evaluate to put simple text in a cell, sort of, it actually does an evaluation of the literal string, perhaps a combination of the = and then the final carriage return
Ws.Range("B1").Clear: Debug.Print "=""Text in Formula in Excel""" ' It is always worth doing this to see what text Evaliate(" ") actually sees inside the " " It gives in this case ="Text in Formula in Excel" But this is not quite the equivalent of what you would write in a cell, since Excel would not try to evaluate and error instead https://i.postimg.cc/htQPr8dL/Wtire-Text-in-Formula-in-Excel-in-a-Cell-and-it-will-error.jpg
Ws.Range("B1").Clear: Let Ws.Range("B1") = Evaluate("=""Text in Formula in Excel"""): Debug.Print "=""Text in Formula in Excel""" ' gives ="Text in Formula in Excel" or try ? "=""Text in Formula in Excel""" ="Text in Formula in Excel" This is extra to Evaluate(" ") - it is attempting to evaluate a string of Text in Formula in Excel, like =Text in Formula in Excel and it recognises that as a text, so puts that in the cell Watch : : Evaluate("=""Text in Formula in Excel""") : "Text in Formula in Excel" : Variant/String : Tabelle6.RangeEvaluate
'1b) Something Else
In the first cell, A1, we have a number held as text. The range object seems to know this, and we find that if we try to write that in another cell, ( Let LHS = ) then we don’t get an error, but rather the text is put in. This is a strange thing, and its discussed in more detail somewhere else, ( Post is #21995 Page2 #12 https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page2#Post21995 ) , but important for our considerations here is that it is a range object phenomena, so in '1b) we compare what happens for the RHS of Range(" ") or Evaluate(" ").
The result is the same.
In fact, not known to many people, some Excel functions also return range objects, ( https://eileenslounge.com/viewtopic.php?p=280942#p280942
https://www.myonlinetraininghub.com/excel-functions-that-return-references#comment-84892 February 20, 2021 at 3:18 am ). and we find that the behaviour in what happens for the RHS of Range(" ") or Evaluate(" ") is consistent for this as well, it’s the same again
'1b) Something Else https://www.youtube.com/watch?v=Td3r55oyiu0
Ws.Range("A2").Clear
Let Ws.Range("A2") = Ws.Range("=IF(1,A1)") ' Watch : + : Ws.Range("=IF(1,A1)") : "44" : Object/Range : Tabelle6.RangeEvaluate
Ws.Range("A2").Clear
Let Ws.Range("A2") = Ws.Evaluate("=IF(1,A1)") ' Watch : + : Ws.Evaluate("=IF(1,A1)") : "44" : Variant/Object/Range : Tabelle6.RangeEvaluate
So far so good.
What’s all this got to do with my Evaluate range one liner answer here: https://eileenslounge.com/viewtopic.php?p=309137#p309137
Well, I was trying to get a number held as text to change to a number, (to get rid of the little warning and the alignment difference to that for a number). My solution was based on pseudo code of CellValue x 1, as this is a typical way in Excel, or computing generally, to get a text that looks like a number to become a true number.
It worked.
But then when I looked at this in more detail, I thought it shouldn’t
https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page10
https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page11
, and then I went right back to re learn about range objects in particular with reference to the typical code line of
Range2.Value = Range1.Value
https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page12
I know enough now to start again.
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=23185&viewfull=1#post23185
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=23185&viewfull=1#post23186
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=23189&viewfull=1#post23189
DocAElstein
08-13-2023, 07:43 PM
Some *more notes, (* second time around) in support of this forum post
https://eileenslounge.com/viewtopic.php?p=309137&sid=153876084ed8edf21dbe3e7ff928c881#p309137
Excel - alignment of numeric values in cells? https://eileenslounge.com/viewtopic.php?p=310023#p310023 https://eileenslounge.com/viewtopic.php?p=310024#p310024
I did a solution who’s basic form started like this , pseudo coding
Range2 = Evaluate("=IF(ISNUMBER(A1:F7),1*A1:F7, A1:F7)")
The logic was that
_ if ISNUMBER( ) recognised a number held as text in any cells, then those cells would be multiplied by 1 to change them to normal numbers
_ the final modified range would then be returned/ put in the Range2
It seemed to work. Well it does. But my logic is up the spout, totally.
_ For one thing, ISNUMBER( ) does not recognise a number held as text as a number https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell?p=22079&viewfull=1#post22079
_ On the right hand side, RHS, of a typical code line like this ,
Range2.Value = Range1
, if Range1 is a multi cell range, then nothing at all is returned!!! #21995 #12 https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page2#Post21995
So what the fuck is going on…..
Take a look at the coding in the next posts, https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page2#Post21995
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=23186&viewfull=1#post23186
We are looking at various variations of code lines with a similar RHS Evaluate(" ") to that in my original initial solution. We apply the result to both
_ a test range, which corresponds to the LHS idea of Range2.Value = Range1
_ we also apply it to a Variant variable
_ we also apply it to a Variant variable
We use the test range A6:A7 which has a number held as text and also a normal number
https://i.postimg.cc/fLXddyGQ/A6-A7.jpg
5508 https://i.postimg.cc/vgYDFY80/A6-A7.jpg (https://postimg.cc/vgYDFY80)
https://i.postimg.cc/fLXddyGQ/A6-A7.jpg (https://postimages.org/)
In the coding I have put the results of the Watch Window in the 'comments
Now let’s analyse some of those results
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=23189&viewfull=1#post23189
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page59#post23189
DocAElstein
08-13-2023, 07:43 PM
Coding for last post
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=23185&viewfull=1#post23185
Sub EvaluateSmarter()
Dim Ws1 As Worksheet
Set Ws1 = ThisWorkbook.Worksheets("Sheet1")
Dim vTemp As Variant
Let Range("A10:A11") = Evaluate("=A6:A7") ' Empty! Watch : + : Evaluate("=A6:A7") : : Variant/Object/Range : Sheet1.EvaluateSmarter
' Watch : + : Range("A10:A11") : : Object/Range : Sheet1.EvaluateSmarter
Let vTemp = Evaluate("=A6:A7") ' Watch : + : vTemp : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' - : vTemp(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' + : vTemp(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
' Watch : + : Evaluate("=A6:A7") : : Variant/Object/Range : Sheet1.EvaluateSmarter
Let Ws1.Range("A10:A11") = Ws1.Evaluate("=A6:A7") ' Empty! Watch : + : Ws1.Evaluate("=A6:A7") : : Variant/Object/Range : Sheet1.EvaluateSmarter
' Watch : + : Ws1.Range("A10:A11") : : Object/Range : Sheet1.EvaluateSmarter
Let ActiveSheet.Range("A10:A11") = Ws1.Evaluate("=A6:A7") ' Empty! Watch : + : Ws1.Evaluate("=A6:A7") : : Variant/Object/Range : Sheet1.EvaluateSmarter
' Watch : + : ActiveSheet.Range("A10:A11") : : Variant/Object/Range : Sheet1.EvaluateSmarter
' I am in the worksheet object code module, so Range and Ws1.Range are likely the same
Let Range("A10:A11") = Evaluate("=IF(1=1,A6:A7)") ' Empty Watch : + : Evaluate("=IF(1=1,A6:A7)") : : Variant/Object/Range : Sheet1.EvaluateSmarter
Let vTemp = Evaluate("=IF(1=1,A6:A7)") ' Watch : + : vTemp : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' - : vTemp(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' + : vTemp(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
Let Range("A10:A11") = Evaluate("=IF({1},A6:A7)") ' Watch : - : Evaluate("=IF({1},A6:A7)") : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' - : Evaluate("=IF({1},A6:A7)")(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Evaluate("=IF({1},A6:A7)")(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' - : Evaluate("=IF({1},A6:A7)")(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Evaluate("=IF({1},A6:A7)")(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
Let vTemp = Evaluate("=IF({1},A6:A7)") ' Watch : + : vTemp : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' - : vTemp(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' - : vTemp(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
Let Range("A10:A11") = Evaluate("=1*A6:A7") 'Watch : + : Evaluate("=1*A6:A7") : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' + : Evaluate("=1*A6:A7")(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Evaluate("=1*A6:A7")(1,1) : 44 : Variant/Double : Sheet1.EvaluateSmarter
' + : Evaluate("=1*A6:A7")(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Evaluate("=1*A6:A7")(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
' Watch : + : Range("A10:A11") : : Object/Range : Sheet1.EvaluateSmarter
Let vTemp = Evaluate("=1*A6:A7") ' Watch : + : vTemp : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' + : vTemp(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(1,1) : 44 : Variant/Double : Sheet1.EvaluateSmarter
' + : vTemp(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
Let Range("A10:A11") = Evaluate("=IF(ROW(),A6:A7)") 'Watch : + : Evaluate("=IF(ROW(),A6:A7)") : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' + : Evaluate("=IF(ROW(),A6:A7)")(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Evaluate("=IF(ROW(),A6:A7)")(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' + : Evaluate("=IF(ROW(),A6:A7)")(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Evaluate("=IF(ROW(),A6:A7)")(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
' Watch : + : Range("A10:A11") : : Object/Range : Sheet1.EvaluateSmarter
Let vTemp = Evaluate("=IF(ROW(),A6:A7)") 'Watch : + : vTemp : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' + : vTemp(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' + : vTemp(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
Let Range("A10:A11") = Evaluate("=IF(1=1,A6:A7,A6:A7)") ' Empty Watch : + : Evaluate("=IF(1=1,A6:A7,A6:A7)"): : Variant/Object/Range : Sheet1.EvaluateSmarter
' Watch : + : Range("A10:A11") : : Object/Range : Sheet1.EvaluateSmarter
' Print Evaluate("=IF(1=1,A6:A7,A6:A7)").Address
' $A$6:$A$7
Let Range("A10:A11") = Evaluate("=IF(1=1,A6:A7,A6:A10)") 'Watch : + : Evaluate("=IF(1=1,A6:A7,A6:A10)") : : Variant/Object/Range : Sheet1.EvaluateSmarter
' print Evaluate("=IF(1=1,A6:A7,A6:A10)").address
' $A$6:$A$7
Let Range("A10:A11") = Evaluate("=IF(1=1,A6:A10,A6:A7)") 'Watch : + : Evaluate("=IF(1=1,A6:A10,A6:A7)") : : Variant/Object/Range : Sheet1.EvaluateSmarter
' Print Evaluate("=IF(1=1,A6:A10,A6:A7)").Address
' $A$6:$A$10
Let vTemp = Evaluate("=IF(1=1,A6:A7,A6:A7)") ' Watch : + : vTemp : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' + : vTemp(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' + : vTemp(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
Let Range("A10:A11") = Evaluate("=IF(1=1,A6:A7,1*A6:A7)") ' Empty Watch : + : Evaluate("=IF(1=1,A6:A7,1*A6:A7)") : : Variant/Object/Range : Sheet1.EvaluateSmarter
' Watch : + : Range("A10:A11") : : Object/Range : Sheet1.EvaluateSmarter
Let vTemp = Evaluate("=IF(1=1,A6:A7,1*A6:A7)") ' Watch : + : vTemp : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' + : vTemp(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' + : vTemp(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
Let Range("A10:A11") = Evaluate("=IF(1=1,1*A6:A7,A6:A7)") ' Watch : + : Evaluate("=IF(1=1,1*A6:A7,A6:A7)") : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' + : Evaluate("=IF(1=1,1*A6:A7,A6:A7)")(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Evaluate("=IF(1=1,1*A6:A7,A6:A7)")(1,1) : 44 : Variant/Double : Sheet1.EvaluateSmarter
' + : Evaluate("=IF(1=1,1*A6:A7,A6:A7)")(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Evaluate("=IF(1=1,1*A6:A7,A6:A7)")(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
Let vTemp = Evaluate("=IF(1=1,1*A6:A7,A6:A7)") ' Watch : + : vTemp : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' + : vTemp(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(1,1) : 44 : Variant/Double : Sheet1.EvaluateSmarter
' + : vTemp(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
Let Range("A10:A11") = Evaluate("=IF(1=0,1*A6:A7,A6:A7)") ' Empty Watch : + : Evaluate("=IF(1=0,1*A6:A7,A6:A7)") : : Variant/Object/Range : Sheet1.EvaluateSmarter
Let vTemp = Evaluate("=IF(1=0,1*A6:A7,A6:A7)") ' Watch : + : vTemp : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' + : vTemp(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' + : vTemp(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
Dim Var(1 To 2, 1 To 1) As Variant
Let Var(1, 1) = "44": Let Var(2, 1) = 55 ' Watch : + : Var : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' - : Var(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Var(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' - : Var(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Var(2,1) : 55 : Variant/Integer : Sheet1.EvaluateSmarter
Dim V1(1 To 1) As Variant: Let V1(1) = "44": Dim V2(1 To 1) As Variant: Let V2(1) = 55
Let Var(1, 1) = V1(1): Let Var(2, 1) = V2(1)
' Watch : - : V2 : : Variant/Variant(1 to 1) : Sheet1.EvaluateSmarter
' : V2(1) : 55 : Variant/Integer : Sheet1.EvaluateSmarter
' Watch : + : V1 : : Variant/Variant(1 to 1) : Sheet1.EvaluateSmarter
' : V1(1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' Watch : + : Var : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' - : Var(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Var(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' - : Var(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Var(2,1) : 55 : Variant/Integer : Sheet1.EvaluateSmarter
Let Var(1, 1) = V1(): Let Var(2, 1) = V2() ' Watch : + : Var : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' - : Var(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' + : Var(1,1) : : Variant/Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Var(1,1)(1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' - : Var(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' + : Var(2,1) : : Variant/Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Var(2,1)(1) : 55 : Variant/Integer : Sheet1.EvaluateSmarter
Let Range("A10:A11") = Evaluate("=IF(1,A6:A7,A6:A7)") ' Empty Watch : + : Evaluate("=IF(1,A6:A7,A6:A7)") : : Variant/Object/Range : Sheet1.EvaluateSmarter
Let vTemp = Evaluate("=IF(1,A6:A7,A6:A7)") ' Watch : + : vTemp : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' + : vTemp(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' + : vTemp(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
DocAElstein
08-13-2023, 07:51 PM
More codong for post
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=23185&viewfull=1#post23185
Let Range("A10:A11") = Evaluate("=IF(1,A6:A7,A6:A7)") ' Empty Watch : + : Evaluate("=IF(1,A6:A7,A6:A7)") : : Variant/Object/Range : Sheet1.EvaluateSmarter
Let vTemp = Evaluate("=IF(1,A6:A7,A6:A7)") ' Watch : + : vTemp : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' + : vTemp(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' + : vTemp(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
Let Range("A10:A11") = Evaluate("=IF(ISTEXT(A6:A7),A6:A7,A6:A7)") ' Watch : + : Evaluate("=IF(ISTEXT(A6:A7),A6:A7,A6:A7)") : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' - : Evaluate("=IF(ISTEXT(A6:A7),A6:A7,A6:A7)")(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Evaluate("=IF(ISTEXT(A6:A7),A6:A7,A6:A7)")(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' - : Evaluate("=IF(ISTEXT(A6:A7),A6:A7,A6:A7)")(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Evaluate("=IF(ISTEXT(A6:A7),A6:A7,A6:A7)")(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
Let vTemp = Evaluate("=IF(ISTEXT(A6:A7),A6:A7,A6:A7)") ' Watch : + : vTemp : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' + : vTemp(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' + : vTemp(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
Let Range("A10:A11") = Evaluate("=IF(ISTEXT(A6:A7),A6:A7)") ' Watch : + : Evaluate("=IF(ISTEXT(A6:A7),A6:A7)") : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' - : Evaluate("=IF(ISTEXT(A6:A7),A6:A7)")(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Evaluate("=IF(ISTEXT(A6:A7),A6:A7)")(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' - : Evaluate("=IF(ISTEXT(A6:A7),A6:A7)")(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : Evaluate("=IF(ISTEXT(A6:A7),A6:A7)")(2,1) : Falsch : Variant/Boolean : Sheet1.EvaluateSmarter
Let vTemp = Evaluate("=IF(ISTEXT(A6:A7),A6:A7)") ' Watch : + : Evaluate("=IF(ISTEXT(A6:A7),A6:A7)") : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' + : vTemp(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' + : vTemp(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(2,1) : Falsch : Variant/Boolean : Sheet1.EvaluateSmarter
Let Range("A10:A11") = Evaluate("=IF(ISNUMBER(A6:A7),1*A6:A7,A6:A7)") ' Watch : + : Evaluate("=IF(ISNUMBER(A6:A7),1*A6:A7,A6:A7)") : : Variant/Variant(1 to 2, 1 to 1) : VBAProject.Sheet1.EvaluateSmarter
' + : Evaluate("=IF(ISNUMBER(A6:A7),1*A6:A7,A6:A7)")(1) : : Variant(1 to 1) : VBAProject.Sheet1.EvaluateSmarter
' : Evaluate("=IF(ISNUMBER(A6:A7),1*A6:A7,A6:A7)")(1,1) : "44" : Variant/String : VBAProject.Sheet1.EvaluateSmarter
' + : Evaluate("=IF(ISNUMBER(A6:A7),1*A6:A7,A6:A7)")(2) : : Variant(1 to 1) : VBAProject.Sheet1.EvaluateSmarter
' : Evaluate("=IF(ISNUMBER(A6:A7),1*A6:A7,A6:A7)")(2,1) : 55 : Variant/Double : VBAProject.Sheet1.EvaluateSmarter
Let vTemp = Evaluate("=IF(ISNUMBER(A6:A7),1*A6:A7,A6:A7)") ' Watch : + : vTemp : : Variant/Variant(1 to 2, 1 to 1) : Sheet1.EvaluateSmarter
' + : vTemp(1) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(1,1) : "44" : Variant/String : Sheet1.EvaluateSmarter
' + : vTemp(2) : : Variant(1 to 1) : Sheet1.EvaluateSmarter
' : vTemp(2,1) : 55 : Variant/Double : Sheet1.EvaluateSmarter
End Sub
Sub ArrayShenanigans()
End Sub
Sub Sidiary()
Dim Strs() As String
Let Strs() = Split("44 55") ' Watch : - : Strs() : : String(0 to 1) : Sheet1.Sidiary
' : Strs()(0) : "44" : String : Sheet1.Sidiary
' : Strs()(1) : "55" : String : Sheet1.Sidiary
Dim Sids(0 To 1) As String
Let Sids(0) = "44": Let Sids(1) = "55"
' Watch : - : Sids : : String(0 to 1) : Sheet1.Sidiary
' : Sids(0) : "44" : String : Sheet1.Sidiary
' : Sids(1) : "55" : String : Sheet1.Sidiary
Dim S1(1 To 1) As String: Let S1(1) = "44"
Dim S2(1 To 1) As String: Let S2(1) = "55"
Let Sids(0) = S1(1): Let Sids(1) = S2(1)
' Watch : - : Sids : : String(0 to 1) : Sheet1.Sidiary
' : Sids(0) : "44" : String : Sheet1.Sidiary
' : Sids(1) : "55" : String : Sheet1.Sidiary
Dim Sids21(1 To 2, 1 To 1) As String ' Watch : - : Sids21 : : String(1 to 2, 1 to 1) : Sheet1.Sidiary
Let Sids21(1, 1) = "a": ' + : Sids21(1) : : String(1 to 1) : Sheet1.Sidiary
Let Sids21(2, 1) = "c" ' : Sids21(1,1) : "a" : String : Sheet1.Sidiary
' + : Sids21(2) : : String(1 to 1) : Sheet1.Sidiary
' : Sids21(2,1) : "c" : String : Sheet1.Sidiary
'
Dim Sids12(1 To 1, 1 To 2) As String ' Watch : + : Sids12 : : String(1 to 1, 1 to 2) : Sheet1.Sidiary
Let Sids12(1, 1) = "a": Sids12(1, 2) = "b" ' + : Sids12(1) : : String(1 to 2) : Sheet1.Sidiary
' : Sids12(1,1) : "a" : String : Sheet1.Sidiary
' : Sids12(1,2) : "b" : String : Sheet1.Sidiary
'
Dim Sids22(1 To 2, 1 To 2) As String ' Watch : - : Sids22 : : String(1 to 2, 1 to 2) : Sheet1.Sidiary
Let Sids22(1, 1) = "a": Sids22(1, 2) = "b" ' - : Sids22(1) : : String(1 to 2) : Sheet1.Sidiary
Let Sids22(2, 1) = "c": Sids22(2, 2) = "d" ' : Sids22(1,1) : "a" : String : Sheet1.Sidiary
' : Sids22(1,2) : "b" : String : Sheet1.Sidiary
' + : Sids22(2) : : String(1 to 2) : Sheet1.Sidiary
' : Sids22(2,1) : "c" : String : Sheet1.Sidiary
' : Sids22(2,2) : "d" : String : Sheet1.Sidiary
End Sub
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
https://www.youtube.com/watch?v=jdPeMPT98QU (https://www.youtube.com/watch?v=jdPeMPT98QU)
https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg (https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5 (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl )
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2 (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2)
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
DocAElstein
08-13-2023, 07:51 PM
_................continued from https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=23185&viewfull=1#post23185
Here the test range agaon, A6:A7 which has a number held as text and also a normal number
https://i.postimg.cc/fLXddyGQ/A6-A7.jpg
5508 https://i.postimg.cc/vgYDFY80/A6-A7.jpg (https://postimg.cc/vgYDFY80)
https://i.postimg.cc/fLXddyGQ/A6-A7.jpg (https://postimages.org/)
In the coding in the last two post, https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=23188&viewfull=1#post23188
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=23186&viewfull=1#post23186 , we apply the result to both
_ a test range, which corresponds to the LHS idea of Range2.Value = Range1
_ we also apply it to a Variant variable
Initially we are expecting the RHS, Evaluate(" ") to be returning a range object, ( when it is Let on the LHS to a range ) , even for those code lines using the Excel worksheet function IF, since that is one of the Excel worksheet functions that returns a range object ( https://eileenslounge.com/viewtopic.php?p=280942#p280942
https://www.myonlinetraininghub.com/excel-functions-that-return-references#comment-84892 )
We also see that when we apply the result to a Variant variable, and as typical, we see that Excel seems to oblige to take the values from the returned range object from the RHS
In many of the code lines we confirm this in the 'comments showing the Watch Window results. However we see that sometimes the results retuned to the LHS are identical for the case of LHS the variable or a range.
Hmm … what’s going on there…
Well this phenomena is not so unusual. We see often see a similar phenomenon, or rather we try to make it happen, when
_ something is not giving us array results when we would like to have them,
_ we then empirically try various tricks to get the array of results. Often we end up with some seemingly redundant or extra thing in the expression, that whilst not directly linked to what we are doing, seems to as a by-product make the expression or function return multi values.
You can see in the various code line variations some of the tricks often done. My favourite, a very simple one, is if I have something not returning multiple values as I wish , then this modification usually does it:
Change
something not returning multiple values as I wish
, to:
IF({1}, something not returning multiple values as I wish )
In addition to such a simple trick, we often find that as progress with developing a solution with more things in the expression, then something we do inadvertently does the same thing.
Looking at the very last code line ,
=IF(ISNUMBER(A6:A7),1*A6:A7,A6:A7) ' returns range object in Evaluate(" ")
, and comparing that with results for one such as this
=IF(1=1,1*A6:A7,A6:A7) ' returns array of values in Evaluate(" ")
, tends to suggest that the ISNUMBER(A6:A7) is doing the trick. So the 1* was not doing anything –( it couldn’t because ISNUMBER(A6) does not return true https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell?p=22079&viewfull=1#post22079 ) , but the whole thing was returning an array of values in a Variant element type array, and as we found out here, https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell?p=22084&viewfull=1#post22084 , even if we have strings in the elements, they are not put in as a string, rather Excel seems to correct them to a number
That’s it. We now figured out what was going on. In the next post we give a final solution based on all we have learnt in the past few weeks…..
Excel Functions ISTEXT and ISNUMBER https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page10
Explanations for my original Evaluate Range one liner until I realised I messed up https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page58
Starting again with hindsight https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page59
Range Object Default Properties (Methods?) https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page12
code line type Range2.Value = Range1.Value Question from the web https://www.excelfox.com/forum/showthread.php/2918-Right-Hand-Side-Range-Range-Value-values-Range-Range-Value-only-sometimes-Range-Range-Value-Anomaly?p=23192&viewfull=1#post23192
Have another think about a solution , next post
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
https://www.youtube.com/watch?v=jdPeMPT98QU (https://www.youtube.com/watch?v=jdPeMPT98QU)
https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg (https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5 (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl )
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2 (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2)
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
DocAElstein
08-13-2023, 07:51 PM
This is post 23187
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=23187&viewfull=1#post23187
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page59#post23187
The new solution
Having done all the donkey work, and now, knowing probably better than anyone what it is all about we can go straight into some solutions.
Sub SimplerSolutionDevelopment() ' https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=23187&viewfull=1#post23187
Rem 0 test data range
Dim Ws1 As Worksheet
Set Ws1 = ThisWorkbook.Worksheets("Sheet1")
Dim Rng As Range
Set Rng = Worksheets.Item("Sheet1").Range("A1:F7")
Rem 1
Rng.Offset(0, Rng.Columns.Count + 1).Clear
'1a These do nothing, and we know why now https://www.excelfox.com/forum/showthread.php/2918-Right-Hand-Side-Range-Range-Value-values-Range-Range-Value-only-sometimes-Range-Range-Value-Anomaly?p=23192&viewfull=1#post23192
Let Rng.Offset(0, Rng.Columns.Count + 1) = Range("A1:F7")
Let Rng.Offset(0, Rng.Columns.Count + 1) = Evaluate("A1:F7")
'1b(i) a trick will do it
' Let Rng.Offset(0, Rng.Columns.Count + 1) = Range("IF({1},A1:F7)") ' Run time error '1004'
Let Rng.Offset(0, Rng.Columns.Count + 1) = Evaluate("IF({1},A1:F7)")
'Watch : - : Evaluate("IF({1},A1:F7)") : : Variant/Variant(1 to 7, 1 to 6) : Sheet1.SimplerSolutionDevelopment
' https://i.postimg.cc/nCt7df7P/Evaluate-IF-1-A1-F7.jpg (https://postimg.cc/nCt7df7P)
'1b(ii)
Let Rng.Offset(0, Rng.Columns.Count + 1) = Evaluate("IF(A1:F7="""","""",IF({1},A1:F7))")
' Watch : + : Evaluate("IF(A1:F7="""","""",IF({1},A1:F7))") : : Variant/Variant(1 to 7, 1 to 6) : Sheet1.SimplerSolutionDevelopment
' https://i.postimg.cc/4H3KLxMT/Evaluate-IF-A1-F7-IF-1-A1-F7.jpg (https://postimg.cc/4H3KLxMT)
'1b(iii)
Rng.Offset(0, Rng.Columns.Count + 1).Clear
Let Rng.Offset(0, Rng.Columns.Count + 1) = Evaluate("IF(A1:F7="""","""",A1:F7)")
' Watch : + : Evaluate("IF(A1:F7="""","""",A1:F7)") : : Variant/Variant(1 to 7, 1 to 6) : Sheet1.SimplerSolutionDevelopment
' https://i.postimg.cc/6T6G5MQ1/Evaluate-IF-A1-F7-A1-F7.jpg (https://postimg.cc/6T6G5MQ1)
'1c)
Rng.Offset(0, Rng.Columns.Count + 1).Clear
Let Rng.Offset(0, Rng.Columns.Count + 1) = Range("A1:F7").Value(RangeValueDataType:=xlRangeValueDefault)
' Watch : + : Range("A1:F7").Value : : Variant/Variant(1 to 7, 1 to 6) : Sheet1.SimplerSolutionDevelopment
' https://i.postimg.cc/grh8q2wh/Range-A1-F7-Value.jpg (https://postimg.cc/grh8q2wh)
Rng.Offset(0, Rng.Columns.Count + 1).Clear
Let Rng.Offset(0, Rng.Columns.Count + 1) = Evaluate("A1:F7").Value(RangeValueDataType:=xlRangeValueDefault)
' Watch : + : Evaluate("A1:F7").Value : : Variant/Variant(1 to 7, 1 to 6) : Sheet1.SimplerSolutionDevelopment
' https://i.postimg.cc/xX5KJpXF/Evaluate-A1-F7-Value.jpg (https://postimg.cc/xX5KJpXF)
End Sub
Conclusions / A final solution(s)
In the coding above, we do a very simple trick in '1b(i) to get the array of values passed to the LHS, this sort of thing
Range2 = Evaluate("IF({1},A1:F7)")
https://i.postimg.cc/DySgw2zn/Evaluate-IF-1-A1-F7.jpg (https://postimg.cc/nCt7df7P)
.
.
.
.
..
.
.
.
.
..
.
.
.
.
..
.
.
.
That is OK, it almost gets what we want, but we see that we have the problem of just an empty cell returning 0 in the tweaked Evaluate(" ") solution, https://i.postimg.cc/4NF4tH97/problem-of-just-an-empty-cell-returning-0-in-the-tweaked-Evaluate.jpg
: Evaluate("IF({1},A1:F7)")(2,6) : 0 : Variant/Double : Sheet1.SimplerSolutionDevelopment
: Evaluate("IF({1},A1:F7)")(3,6) : 0 : Variant/Double : Sheet1.SimplerSolutionDevelopment
https://i.postimg.cc/Xpd06Jx4/problem-of-just-an-empty-cell-returning-0-in-the-tweaked-Evaluate.jpg (https://postimg.cc/Xpd06Jx4)
We had this problem in the original solution as well, https://eileenslounge.com/viewtopic.php?p=309137#p309137 ,….. If you have any cells in the selection that are empty, then you had better use this next version instead, or else it will change empty cells into a cell with a 0 in it …..
This is perhaps understandable because we are doing mathematical calculations in VBA in Variants, and I am taking a guess that VBA calculations default to 0. Or some similar explanation.
As in the original solution, we can remove that problem by a modification, as in '1b(ii) , so we have like
Range2 = Evaluate("IF(A1:F7="""","""",IF({1},A1:F7))")
In fact, as we often find, the extra bit does the trick, so we can remove the IF({1},____) and so simplify the solution to like as in '1b(iii)
Range2 = Evaluate("IF(A1:F7="""","""",A1:F7)")
( One small thing to note with '1b(ii) and '1b(iii) is that the Empty is replace by / shown as "" , a zero length String ""
: Evaluate("IF(A1:F7="""","""",IF({1},A1:F7))")(2,6) : "" : Variant/String : Sheet1.SimplerSolutionDevelopment
: Evaluate("IF(A1:F7="""","""",IF({1},A1:F7))")(3,6) : "" : Variant/String : Sheet1.SimplerSolutionDevelopment
: Evaluate("IF(A1:F7="""","""",A1:F7)")(2,6) : "" : Variant/String : Sheet1.SimplerSolutionDevelopment
: Evaluate("IF(A1:F7="""","""",A1:F7)")(3,6) : "" : Variant/String : Sheet1.SimplerSolutionDevelopment )
Evaluate("IF(A1:F7="""","""",IF({1},A1:F7))") Evaluate("IF(A1:F7="""","""",A1:F7)")
https://i.postimg.cc/HnwQLJ9j/Evaluate-IF-A1-F7-IF-1-A1-F7.jpg (https://postimg.cc/4H3KLxMT)https://i.postimg.cc/Wpgm8Kcj/Evaluate-IF-A1-F7-A1-F7.jpg (https://postimg.cc/6T6G5MQ1)
.
.
..
.
.
.
.
.
.
..
.
.
.
.
.
.
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
https://www.youtube.com/watch?v=jdPeMPT98QU (https://www.youtube.com/watch?v=jdPeMPT98QU)
https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg (https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5 (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl )
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2 (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2)
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
_.______________________
Well, we got as far as we did before with the original solution, but done it correctly this time.
But we can do another offering:
See next post
DocAElstein
08-13-2023, 07:51 PM
Another solution
Instead of relying on a trick to change the RHS Evaluate("A1:F7") to return an array of values instead of a range object, we can keep the range object, and apply the .Value(RangeValueDataType:=xlRangeValueDefault) Property / Method thing to it, which returns an array of values. (We can also do that to the usual range object, Range("A1:F7")
In '1c) we do that and get very similar results, and have the advantage that the empty cell(s) are returned as empty cells without needing to do anything further
Here the results for that compared to the very first Evaluate("IF({1},A1:F7)")
Evaluate("IF({1},A1:F7)") Range("A1:F7").Value Evaluate("A1:F7").Value
https://i.postimg.cc/v85zgQFs/Evaluate-IF-1-A1-F7.jpg (https://postimages.org/) https://i.postimg.cc/zvwS9kSB/Range-A1-F7-Value.jpg (https://postimages.org/) https://i.postimg.cc/7LcV7hZx/Evaluate-A1-F7-Value.jpg (https://postimg.cc/QBQ1ZX7P)
.
.
.
.
.
.
.
.
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
https://www.youtube.com/watch?v=jdPeMPT98QU (https://www.youtube.com/watch?v=jdPeMPT98QU)
https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg (https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5 (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl )
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2 (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2)
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
DocAElstein
08-14-2023, 04:58 PM
test
Excel Functions ISTEXT and ISNUMBER https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page10
Explanations for my original Evaluate Range one liner until I realised I messed up https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page58
Starting again with hindsight. The new solution https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page59
Range Object Default Properties (Methods?) https://www.excelfox.com/forum/showthread.php/2914-Tests-and-Notes-on-Range-objects-in-Excel-Cell/page12
code line type Range2.Value = Range1.Value Question from the web https://www.excelfox.com/forum/showthread.php/2918-Right-Hand-Side-Range-Range-Value-values-Range-Range-Value-only-sometimes-Range-Range-Value-Anomaly?p=23192&viewfull=1#post23192
.
.
.
.
.
.
.
.
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
https://www.youtube.com/watch?v=jdPeMPT98QU (https://www.youtube.com/watch?v=jdPeMPT98QU)
https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg (https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5 (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl )
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh)
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2 (https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2)
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
DocAElstein
02-07-2024, 08:57 PM
Later
DocAElstein
02-07-2024, 08:58 PM
In support of these forum posts
https://www.excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA-CSV-stuff?p=23981&viewfull=1#post23981
https://eileenslounge.com/viewtopic.php?p=313971#p313971
Developing an Evaluate Range solution
In column A we have things like this: (just showing the first few words in each row for clarity )
Shell.OmitFromView -- PKEY_Shell_Omi …..
SimpleRating -- PKEY_SimpleRating // Type: UInt32 – VT…..
Size -- PKEY_Size ……….// Type: UInt64 – VT
SoftwareUsed -- PKEY_SoftwareUsed// Type: Strin …
SourceItem -- PKEY_SourceItem // Typ …….
I only want this sort of thing
Shell.OmitFromView
SimpleRating
Size
SoftwareUsed
SourceItem
, so the first character set before any spaces
Spreadsheet Formula
So lets try to get those character sets in the fourth column ( Column D ) ,.
Building up a spreadsheet formula to do that is easy. Here is an example:
_____ Workbook: WSO_PropNamesExtended.xls ( Using Excel 2013 32 bit )
Row\ColABC
2Address.Country -- PKEY_Address_Country
// Type: String -- VT_LPWSTR (For variants: VT_BSTR)
// FormatID: {C07B4199-E1DF-4493-B1E1-DE5946FB58F8}, 100
DEFINE_PROPERTYKEY(PKEY_Address_Country, 0xC07B4199, 0xE1DF, 0x4493, 0xB1, 0xE1, 0xDE, 0x59, 0x46, 0xFB, 0x58, 0xF8, 100);
#define INIT_PKEY_Address_Country { { 0xC07B4199, 0xE1DF, 0x4493, 0xB1, 0xE1, 0xDE, 0x59, 0x46, 0xFB, 0x58, 0xF8 }, 100 }
=SEARCH(" -- PKEY",A2)=LEFT(A2,B2-1)
3Address.CountryCode -- PKEY_Address_CountryCode
// Type: String -- VT_LPWSTR (For variants: VT_BSTR)
// FormatID: {C07B4199-E1DF-4493-B1E1-DE5946FB58F8}, 101
DEFINE_PROPERTYKEY(PKEY_Address_CountryCode, 0xC07B4199, 0xE1DF, 0x4493, 0xB1, 0xE1, 0xDE, 0x59, 0x46, 0xFB, 0x58, 0xF8, 101);
#define INIT_PKEY_Address_CountryCode { { 0xC07B4199, 0xE1DF, 0x4493, 0xB1, 0xE1, 0xDE, 0x59, 0x46, 0xFB, 0x58, 0xF8 }, 101 }
=SEARCH(" -- PKEY",A3)=LEFT(A3,B3-1)
4Address.Region -- PKEY_Address_Region
// Type: String -- VT_LPWSTR (For variants: VT_BSTR)
// FormatID: {C07B4199-E1DF-4493-B1E1-DE5946FB58F8}, 102
DEFINE_PROPERTYKEY(PKEY_Address_Region, 0xC07B4199, 0xE1DF, 0x4493, 0xB1, 0xE1, 0xDE, 0x59, 0x46, 0xFB, 0x58, 0xF8, 102);
#define INIT_PKEY_Address_Region { { 0xC07B4199, 0xE1DF, 0x4493, 0xB1, 0xE1, 0xDE, 0x59, 0x46, 0xFB, 0x58, 0xF8 }, 102 }
=SEARCH(" -- PKEY",A4)=LEFT(A4,B4-1)
Worksheet: Ext(Hidden)proph
_____ Workbook: WSO_PropNamesExtended.xls ( Using Excel 2013 32 bit )
Row\ColABC
2Address.Country -- PKEY_Address_Country
// Type: String -- VT_LPWSTR (For variants: VT_BSTR)
// FormatID: {C07B4199-E1DF-4493-B1E1-DE5946FB58F8}, 100
DEFINE_PROPERTYKEY(PKEY_Address_Country, 0xC07B4199, 0xE1DF, 0x4493, 0xB1, 0xE1, 0xDE, 0x59, 0x46, 0xFB, 0x58, 0xF8, 100);
#define INIT_PKEY_Address_Country { { 0xC07B4199, 0xE1DF, 0x4493, 0xB1, 0xE1, 0xDE, 0x59, 0x46, 0xFB, 0x58, 0xF8 }, 100 }
16Address.Country
3Address.CountryCode -- PKEY_Address_CountryCode
// Type: String -- VT_LPWSTR (For variants: VT_BSTR)
// FormatID: {C07B4199-E1DF-4493-B1E1-DE5946FB58F8}, 101
DEFINE_PROPERTYKEY(PKEY_Address_CountryCode, 0xC07B4199, 0xE1DF, 0x4493, 0xB1, 0xE1, 0xDE, 0x59, 0x46, 0xFB, 0x58, 0xF8, 101);
#define INIT_PKEY_Address_CountryCode { { 0xC07B4199, 0xE1DF, 0x4493, 0xB1, 0xE1, 0xDE, 0x59, 0x46, 0xFB, 0x58, 0xF8 }, 101 }
20Address.CountryCode
4Address.Region -- PKEY_Address_Region
// Type: String -- VT_LPWSTR (For variants: VT_BSTR)
// FormatID: {C07B4199-E1DF-4493-B1E1-DE5946FB58F8}, 102
DEFINE_PROPERTYKEY(PKEY_Address_Region, 0xC07B4199, 0xE1DF, 0x4493, 0xB1, 0xE1, 0xDE, 0x59, 0x46, 0xFB, 0x58, 0xF8, 102);
#define INIT_PKEY_Address_Region { { 0xC07B4199, 0xE1DF, 0x4493, 0xB1, 0xE1, 0xDE, 0x59, 0x46, 0xFB, 0x58, 0xF8 }, 102 }
15Address.Region
Worksheet: Ext(Hidden)proph
Now, in column D we simply paste the last working formula , ( from column C ) , and then look from the left of column C so as to get the formula only referring to the first column. That way we can do away with the columns B and C
_____ Workbook: WSO_PropNamesExtended.xls ( Using Excel 2013 32 bit )
Row\ColD
2=LEFT(A2,SEARCH(" -- PKEY",A2)-1)
3=LEFT(A3,SEARCH(" -- PKEY",A3)-1)
4=LEFT(A4,SEARCH(" -- PKEY",A4)-1)
Worksheet: Ext(Hidden)proph
VBA Evaluate Range solution.
The simple direct Evaluate Range implementation would be
Evaluate("LEFT(A2:A1055,SEARCH("" -- PKEY"",A2:A1055)-1)")
As sometimes happens we find that this needs a little trick to get all the available values, since otherwise just the first value is returned.
This final working Evaluate Range line does the trick,
Evaluate("IF({1},LEFT(A2:A1055,SEARCH("" -- PKEY"",A2:A1055)-1))")
Here is a full coding to get the property name words in column E in the uploaded file
Option Explicit
' https://www.excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA-CSV-stuff?p=23979&viewfull=1#post23979
Sub ExtendedPropertiesList()
' Rem 1 Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "propkey h.txt" '
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
' Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
'Get #FileNum, , TotalFile
' Or http://www.eileenslounge.com/viewtopic.php?p=295782&sid=f6dcab07c4d24e00e697fe4343dc7392#p295782
Let TotalFile = Input(LOF(FileNum), FileNum)
Close #FileNum
' Rem 2 Split the Prophs
Dim arrProphs() As String: Let arrProphs() = Split(TotalFile, "// Name: System.", -1, vbBinaryCompare)
' 2a) Quick look at list
Dim LCnt As Long: Let LCnt = UBound(arrProphs())
Dim Rws() As Variant, Clms() As Variant, VertList() As Variant
Let Rws() = Evaluate("ROW(1:" & LCnt + 1 & ")/ROW(1:" & LCnt + 1 & ")")
Let Clms() = Evaluate("ROW(1:" & LCnt + 1 & ")")
Let VertList() = Application.Index(arrProphs(), Rws(), Clms())
Let Me.Range("A1:A" & LCnt & "") = VertList()
Me.Cells.WrapText = False
'' 2b) Look at some example props using function WtchaGot_Unic_NotMuchIfYaChoppedItOff
'' The next text is copied from cell A 350
'' "Size -- PKEY_Size
'' // Type: UInt64 -- VT_UI8
'' // FormatID: (FMTID_Storage) {B725F130-47EF-101A-A5F1-02608C9EEBAC}, 12 (PID_STG_SIZE)
'' //
'' //
'' DEFINE_PROPERTYKEY(PKEY_Size, 0xB725F130, 0x47EF, 0x101A, 0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC, 12);
'' #define INIT_PKEY_Size { { 0xB725F130, 0x47EF, 0x101A, 0xA5, 0xF1, 0x02, 0x60, 0x8C, 0x9E, 0xEB, 0xAC }, 12 }
''
'' "
'' The next text is copied from watch window at arrProphs()(349)
'' : arrProphs()(349) : "Size -- PKEY_Size
'' // Type: UInt64 -- VT_UI8
'' // FormatID: (FMTID_Storage) {B725F130-47EF-101A-A5F1-02608C9EEBAC}, 12 (PID_STG_SIZE)
'' //
'' //
'' DEFINE_PROPERTYKEY(PKE"
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(arrProphs()( 349), "Size349")
Rem 3 Evaluate Range to get just the property to use in like .ExtendedProperty("System.Size")
Dim arrExtProps() As Variant '
Let arrExtProps() = Me.Evaluate("IF({1},LEFT(A2:A1055,SEARCH("" -- PKEY"",A2:A1055)-1))")
' 3b) Paste into a worksheet column
Let Me.Range("E2:E1055") = arrExtProps()
'Stop
End Sub
https://i.postimg.cc/90Znck96/Ext-Prop-List-In-Column-E.jpg
5753 https://i.postimg.cc/sGfccwwm/Ext-Prop-List-In-Column-E.jpg (https://postimg.cc/sGfccwwm)
https://i.postimg.cc/90Znck96/Ext-Prop-List-In-Column-E.jpg (https://postimages.org/)
DocAElstein
03-04-2024, 05:56 PM
This is post
https://www.excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA-CSV-stuff?p=24048&viewfull=1#post24048
https://www.excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA-CSV-stuff?p=24048&viewfull=1#post24048
https://www.excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA-CSV-stuff/page12#post24048
https://www.excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA-CSV-stuff/page12#post24048
DocAElstein
03-05-2024, 01:59 AM
saafsfaf
DocAElstein
03-06-2024, 02:18 AM
this is post
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24083&viewfull=1#post24050
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24050&viewfull=1#post24050
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page60#post24050
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page60#post24050
Quotes in VBA
In Excel spreadsheets, within a formula, we would enclose text we wanted to appear as text, in a quote pair, as this signalises to Excel that we want a literal text, rather than that the text is a name, function or some other specific thing that the text represents in Spreadsheet syntax. That is so that we can combine in a cell text and the result of a formula.
Example, type in a cell this ="Result is " & 1+1 then you will still see that in the formula bar, but in the cell you would see Result is 2
The & is just the VBA syntax for "sticking" things together, so this formula, for example, would give the same result in the cell ="Res" & "ult is " & 1+1
It follows, perhaps, that we can put plain text in a cell with a formula, as an alternative to simply putting the text in, for example , typing ="Hello" in a cell will result in that in the formula bar, but in the cell we will see Hello
Quotes in VBA
For VBA it is the same: In other words, what is within a quote, will not be regarded directly as part of the coding, but rather refers to some actual text that will be used in some way, depending on what the coding associated with it is about. For us here, the text within the quotes is the text that we finally want to see.
Working in VBA, ( or in a spreadsheet cell), to produce a string that we want to show a quote, becomes problematic. It is not clear if anybody really knows how and why we can get over this problem. There is no real documentation, although you might find the simple rule or explanation along the lines of…. Strings in VBA are delimited with quotation marks. If you want to include quotation marks in your string, you need to double them. Otherwise, the VBA compiler will not recognize that they should not end the string….
Well, that may be a correct statement, but I am not sure if that is a good explanation and whether it works by design or accident.
For me the following ideas helps to remember and possibly have an explanation or at least a theory that can explain the results and behaviour: It’s not too distant or different to that statement, it is an idea that helps me to remember, and possibly an
explanation:
The syntax will not allow a single quote within a quote pair, as the complier requires a pair. The syntax of VBA coding would also understandably find these strange.
__________ = "___ "____"___ "
__________ = "xyz"____"xyz"
But consider what might happen when we bring the inner quote pair together
__________ = "xyz""xyz"
I am thinking that we may have some sort of strange dynamic equilibrium situation, whereby simultaneously the quote pair syntax is satisfied and we have two joined pairs of text, ( "intimately joined"), which VBA sees on the compile as something like this
xy"xyz""
xyzxy""xyz"
, but because of this intimacy of the join, the position of the two inner quotes appears in the same place, meaning that the string is joined,- a quote may be defined twice, but in the same place, resulting in the final string as seen by VBA as
xyzxyz"xyz
Another way perhaps for thinking about is that they are actually a bit further than intimately joined, a character is entwined. By definition, the actual final literal string starts or stops on the other side of the quote, either after or before the quote. If you look at some of those coloured sketches you can perhaps imagine that the stop and start of the two literal bits of literal text is in the same place, which further joins them by two quotes merged into one.
Using Debug.Print to aid in string construction
Even with a good understanding of quotes in VBA, it is very easy to make a mistake. This general rule can help:
Printing out the string you have attempted to construct in the immediate window, will show it as VBA sees it after compile, and shows what VBA, after compile, will be trying to put in a cell via a code line like
Let Range("C1") = The string you have constructed
So, that string shown in the immediate window must be syntaxly kosher for an Excel cell, in otherwords it must look like the string as you would manually write it in a cell. So for putting a formula in a cell, something like this would be OK
= "a" & "b"
, resulting in the value
ab
showing in the cell, ( and in the formula bar you will see = "a" & "b" , just as in the immediate window )
On the other hand, something like these showing for a Debug.Print of your constructed string, would likely error when used
= "a" & b"
= "a" & ""b"
= ""a"" & "b"
So finally, in ' 2a we have a string construction that we are happy with to put a formula in a cell which will be the Excel spreadsheet formula, ="a"&Char(10)&Char(13)&"b" , as indeed we see both in the formula Bar, and in the immediate window if using
Debug.Print "=" & """a""" & "&" & "Char(13)&Char(10)" & "&" & """b""" & ""
To briefly explain that final string construction in words
______ "=" & """a""" & "&" & "Char(13)&Char(10)" & "&" & """b""" & ""
The outer most quotes are those always required in VBA to signalise that we are giving literal text.
Within those outer quotes, in VBA coding we may build up the string from further string elements. (The string can also be built up from VBA things returning strings or numbers, as we will do in the next post. Here we are only using other string elements), The syntax of VBA will require further enclosing quotes for every further string elements, and furthermore, VBA syntax requires an ampersand symbol, _ & _ , to join these strings, thus
______ "__" & "¬¬¬¬____" & "asskasasaf"
In green is the literal text, as we would write it in a cell.
Excel spreadsheet syntax requires in the final written cell formula text ampersands, & , which will be here literal text, hence must be enclosed with VBA quote pairs, thus
"&"
Finally, the Excel spreadsheet syntax requires that a literal text such as the character a, must be enclosed in the cell in quotes, but as we discussed in quotes in VBA something like this would error , ""a"" , we require to effectively double quote where we want a final single quote in the final string , """a"""
The final value in the cell would be
a
b
We have there 4 characters, pseudo like, (and it’s a bit subjective/ arbitrary of me, how I show them here in this pseudo form, just for explanation purposes: )
a vbCr
vbLf b
Some final minor notes:
_ If we are in in non English Excel, as I am, we can type either of these in the Immediate window to get the English syntax.
? range("C1").Formula
Debug.Print range("C1").Formula
_ Once we have the final string, we can often simplify, mainly by removing some VBA joining bits, since they are redundant when linking only literal text – the text can simply appear together.
______ "=""a""&Char(13)&Char(10)&""b"""
However, from experience I would only do this, if ever, at a final stage, since the careful explicit constructions are usually easier to build up and debug. Indeed, with hindsight, I might separate all the final cell texts of "a" and "b", as shown within the VBA construction, into the 3 characters of a quote, an a , and a final quote, just so as to make them clearly correspond to the explanations given of the quotes in VBA
______ "=" & """" & "a" & """" & "&" & "Char(13)&Char(10)" & "&" & """" & "b" & """" & ""
In words, just as you would write in the cell ,
=
and
a quote "
and
a
and
a quote "
and
a ampersand &
and
a quote "
and
the two joined text (functions), Char(13)&Char(10)
and
a ampersand &
and
a quote "
and
b
and
a quote "
https://i.postimg.cc/j2SJH7tY/a-CHAR-13-CHAR-10-b.jpg
5795 https://i.postimg.cc/k6L49D2T/a-CHAR-13-CHAR-10-b.jpg (https://postimg.cc/k6L49D2T)
https://i.postimg.cc/j2SJH7tY/a-CHAR-13-CHAR-10-b.jpg (https://postimages.org/)
DocAElstein
03-06-2024, 02:18 AM
Later
DocAElstein
03-09-2024, 10:10 PM
Option Explicit
Sub CarriageReturnLineFeedExcelVBAText() ' https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24054&viewfull=1#post24054
On Error GoTo Bed
Rem 0 A few things to make things in the demo look closer to what they are
Call TidyCellView ' When experimenting it may be a good idea to occaisionally do this again, as Excel occaisionally may change things if it geusses incorrrectly what we want to see
Debug.Print
Rem 1 Simple Text to put in a cell
Debug.Print "Rem 1a": Let Range("B1") = "Rem 1" & vbLf & """" & "a" & """" & " " & "&" & " vbCr " & "&" & " vbLf " & "&" & " " & """" & "b" & """" ' I get this from the Immdiszr eindow after I wrote it in https://i.postimg.cc/3rSpmQ94/Use-Wtcha-Got-in-Immediate-window-to-get-tricky-cell-text-in-VBA-syntax-form.jpg
Let Range("B1").Characters(Start:=1, Length:=6).Font.Color = -11489280: Let Range("B1").Characters(Start:=7, Length:=23).Font.ColorIndex = xlAutomatic
Debug.Print "a" & vbCr & vbLf & "b" ' shows a
' b
Debug.Print "a" & Chr(13) & Chr(10) & "b" ' shows a
' b
Let Range("B3") = "a" & vbCr & vbLf & "b" ' shows in cell a
' b
Let Range("B4") = Evaluate("a" & vbCr & vbLf & "b") ' In cell #WERT! - it appears to be returning Error 2015
'Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(Range("A1").Value) ' "a" & vbCr & vbLf & "b"
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff("a" & vbCr & vbLf & "b") ' "a" & vbCr & vbLf & "b"
Stop: Call TidyCellView: Debug.Print
' LHS https://www.excelfox.com/forum/showthread.php/2956-Right-Hand-Side-Range-Range-Value-values-Range-Range-Value-only-sometimes-Range-Range-Value-Anomaly
' 1b
Debug.Print "Rem 1b": Let Range("C1") = "Rem 1b" & vbLf & """" & "a" & """" & " " & "&" & " Evaluate" & "(" & """" & "Char" & "(" & "13" & ")" & "&" & "Char" & "(" & "10" & ")" & """" & ")" & " " & "&" & " " & """" & "b" & """"
Let Range("C1").Characters(Start:=1, Length:=7).Font.Color = -11489280: Let Range("C1").Characters(Start:=8, Length:=41).Font.ColorIndex = xlAutomatic
Debug.Print "a" & Evaluate("Char(13)&Char(10)") & "b" ' shows a
' b
Let Range("C3") = "a" & Evaluate("Char(13)&Char(10)") & "b" ' shows in cell a
' b
'Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(Range("B1").Value) ' "a" & vbCr & vbLf & "b"
Let Range("C4") = Evaluate("a" & Evaluate("Char(13)&Char(10)") & "b") ' In cell #WERT! - it appears to be returning Error 2015
Stop: Call TidyCellView: Debug.Print
' 1c(i) Note Evaluate(vbCr & vbLf) in watch gives gives Watch : : Evaluate(vbCr & vbLf) : Fehler 2015 : Variant/Error
Debug.Print "Rem 1c(i)": Let Range("D1") = "Rem 1c" & _
vbLf & """" & "a" & """" & " " & "&" & " Evaluate" & "(" & "vbCr " & "&" & " vbLf" & ")" & " " & "&" & " " & """" & "b" & """"
Let Range("D1").Characters(Start:=1, Length:=7).Font.Color = -11489280: Let Range("D1").Characters(Start:=8, Length:=33).Font.ColorIndex = xlAutomatic
Debug.Print "a" & Evaluate(vbCr & vbLf) & "b" ' Fatal Type Mismatch Error
Let Range("D3") = "a" & Evaluate(vbCr & vbLf) & "b" ' Fatal Type Mismatch Error
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff("a" & Evaluate(vbCr & vbLf) & "b") 'Fatal Type Mismatch Error
Let Range("D4") = Evaluate("a" & Evaluate(vbCr & vbLf) & "b") ' Fatal Type Mismatch Error
Stop: Call TidyCellView: Debug.Print
' 1c(ii) Note Evaluate("""" & vbCr & vbLf & """") Watch : : Evaluate("""" & vbCr & vbLf & """") : "
' " : Variant/String if copied here, but looks like " " in the watch window https://i.postimg.cc/L6C24trX/Warch-Window-dont-display-a-line-break.jpg
Debug.Print "Rem 1c(ii)": Let Range("E1") = "Rem 1c(ii)" & _
vbLf & """" & "a" & """" & " " & "&" & " Evaluate" & "(" & """" & """" & """" & """" & " " & "&" & " vbCr " & "&" & " vbLf " & "&" & " " & """" & """" & """" & """" & ")" & " " & "&" & " " & """" & "b" & """"
Let Range("E1").Characters(Start:=1, Length:=11).Font.Color = -11489280: Let Range("E1").Characters(Start:=12, Length:=47).Font.ColorIndex = xlAutomatic
Debug.Print Evaluate("""" & vbCr & vbLf & """") ' This seems to take the cursor down 2 places, but as Debug.Print takes routinely the cursor down once, our bit must have took it down once
Debug.Print "a" & Evaluate("""" & vbCr & vbLf & """") & "b" ' shows a
' b
Let Range("E3") = "a" & Evaluate("""" & vbCr & vbLf & """") & "b" ' shows in cell a
' b
Let Range("E4") = Evaluate("a" & Evaluate("""" & vbCr & vbLf & """") & "b") ' In cell #WERT! - it appears to be returning Error 2015
Let Range("E4") = "#WERT! #VALUE is Excel's way of saying, ""There's something wrong with the way your formula is typed. Or, there's something wrong with the cells you are referencing."" The error is very general, and it can be hard to find the exact cause of it"
Debug.Print Len("""" & vbCr & vbLf & """") ' 4
Debug.Print Len(Evaluate("""" & vbCr & vbLf & """")) ' 2
'Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(Range("B1").Value) ' "a" & vbCr & vbLf & "b"
Stop: Call TidyCellView: Debug.Print
Debug.Print
Stop: Stop: Stop
' 1d Some conclusions
Debug.Print "Rem 1d"
Debug.Print """" & vbCr & vbLf & """" ' "
' "
'Call WtchaGot_Unic_NotMuchIfYaChoppedItOff("""" & vbCr & vbLf & """") ' 4 characters quote https://i.postimg.cc/QMPndxSn/4-characters-quote-vb-Cr-vb-Lf-quote.jpg https://postimg.cc/gwVKMpCv
Debug.Print
Debug.Print
Exit Sub
Bed:
Debug.Print Err.Number
Debug.Print Err.Description
Resume Next
End Sub
Sub CarriageReturnLineFeedExcelVBAFormula()
DocAElstein
03-09-2024, 10:11 PM
this is post #595
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24055&viewfull=1#post24055
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24055&viewfull=1#post24055
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page60#post24055
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page60#post24055
Problems with vbCr & vbLf in formulas and Evaluate(" ")
Review/ Introduction of what we are doing
In this post we will consider the first parts of the demo coding from the last post, or rather Sub CarriageReturnLineFeedExcelVBAText()
This will take us up to the point of the issue of vbCr & vbLf in formulas and Evaluate(" "), and so serve as an introduction and review of relevant concepts required to be understood before tacking the issue one step further into formulas
Rem 1 Puts stuff in a cell, fairly straight forward,
Range("B3") = "a" & vbCr & vbLf & "b"
( but even that is not so well understood. I understand it better than anyone at the moment. https://www.excelfox.com/forum/showthread.php/2956-Right-Hand-Side-Range-Range-Value-values-Range-Range-Value-only-sometimes-Range-Range-Value-Anomaly ). We can best say that the simplest syntax of the LHS, as we have there, says "put in the cell, what is on the RHS, like wot we might do via writing something in a spreadsheet cell and then hitting Enter". That tends to imply putting text, (and / or numbers) in a cell. But I think if we want to learn quicker and better Excel and VBA, then it is advisable not to think like that too much, and rather to leave it a bit open in the mind at "put in the cell, what is on the RHS, as example, as you might do via writing something in and then hitting Enter". Best not tie the thinking down too much on that one, or further revelations I give may not get so easily in the brain )
As far as the RHS is concerned, it is what we put in the cell : In Excel spreadsheets, we can simply write in text
In a formula, we would enclose text we wanted to appear as text, in a quote pair, as this signalises to Excel that we want a literal text, rather than that the text is a name, function or some other specific thing that the text represents in Spreadsheet syntax.
For VBA it is the same: In other words, what is within a quote, will not be regarded directly as part of the coding, but rather refers to some actual text that will be used in some way, depending on what the coding associated with it is about. For us here, the text within the quotes is the text that we finally want to see
But already, we perhaps need to think a bit more carefully about exactly what is happening: VBA made some determination of what "a" & vbCr & vbLf & "b" is. It decided it was a 4 character piece of text. In VBA we represent that something like a vbCr vbLf b, but inside the whatever calculated/ evaluated thing, (bucket, section of pipe or bit of text string, etc) is: The character a; the character feed character; the line feed character; and the character b
' 1b Range("C3") = "a" & Evaluate("Char(13)&Char(10)") & "b"
This gives an initial indication that
_____ = ____ Evaluate("Char(13)&Char(10)")
and
_____ = ______ vbCr & vbLf
may be equivalent. The Evaluate(" ") is presumably returning into VBA what VBA also sees in vbCr & vbLf
' 1c(i) Range("D3") = "a" & Evaluate(vbCr & vbLf) & "b"
This gives an initial indication that
_____ = ____ Evaluate("Char(13)&Char(10)")
and
_____ = ______ vbCr & vbLf
may not be equivalent
' 1c(ii) Range("E3") = "a" & Evaluate("""" & vbCr & vbLf & """") & "b"
This is our first dealing with the issue this Post and the next few Posts is about: We seem to have got over the problem of ' 1c(i)
The issue of this Post and the next few Posts is about that I am trying to explain that.
But first we will do some similar experiments, putting a formula in, ( but that also requires some careful consideration of Quotes in VBA , ( or an Excel cell, for that matter )
But before we go let’s have a Results Summary Conclusion attempt
https://i.postimg.cc/pddjNp40/Sub-Carriage-Return-Line-Feed-Excel-VBAText.jpg
5830 https://i.postimg.cc/87qcMP1W/Sub-Carriage-Return-Line-Feed-Excel-VBAText.jpg (https://postimg.cc/87qcMP1W)
https://i.postimg.cc/pddjNp40/Sub-Carriage-Return-Line-Feed-Excel-VBAText.jpg (https://postimages.org/)
Rem 1d(i) Some conclusions
Perhaps it’s not so unexpected that Evaluate(vbCr & vbLf) gives us problems. Lets say Evaluate() looks for a valid Excel syntax, or perhaps let say Evaluate() looks for a valid Excel name initially, failing that it does the other sort of evaluation based on adding a = at the start. We can consider vbCr and vbLf as variables containing text characters. As such they are not much different from a x and a y
Now Evaluate(" ") was designed to take a string to allow us to build up a final text within the " " __ I think that is put in the cell , and if that is not recognised, then an = is put in front of it and that is tried. Unless, in this example, xy is recognised, such as for a named range, only there after it puts an = at the start. In a cell =xy wont work. ="xy" will work. The " " is a VBA string. For that to give me like in the returned Debug.Print string a leading quote, for example, I need to add a """"
Rem 1d(ii) Some advanced stab in the dark conclusions (Actually with a bit of hindsight from later)
Maybe….
It is likely that if you have got as far as reading this, then you will likely be familiar with the Range(" ")
There are some similarities with Evaluate(" ") and this more familiar Range(" ") _ So that can be a good start point.
These both return something to VBA when the text inside the " " is some recognised Excel spreadsheet syntax convention thing. I suggest there is some sort of flexible/ dynamic = feature wired in which may be used after some attempt without it. Some extra check is then perhaps added to Range(" ") to ensure that a range object is returned. Assuming this idea is correct, then Evaluate(" ") is the same but without this restriction.
( For Range(" ") this can explain the interesting feature we tripped over here (https://eileenslounge.com/viewtopic.php?p=280951#p280951), since a formula is allowed, but only if it returns a range object reference, in other words a name recognised in Excel spreadsheet syntax convention. This last bit sets the limitation of Range(" ")
However, I think the Evaluate(" ") does not share this limitation, and so allows a value, text or numeric to be returned).
Perhaps the Evaluate(" ") can be regarded as doing this pseudo coding
_ If the text is some recognised name or excel reference , Then Return the object, Expose it, run it, or some similar action doing something, Exit
Put a = in front of it.
_ If with the = it is not recognised by Excel spreadsheet syntax convention Then Error
_ If it is a closed workbook reference, then error, since it allows Alan to do things better than most complicated data base stuff, and that’s embarrassing , Error Exit
Return anything that a Variant variable will return.
Evaluate Formula Value)
We are not quite finished.
Evaluate Formula Value(s)
For the case of Evaluate(" ") effectively doing a formula in the " " we end up effective doing an Excel type evaluation, but we are not tied to a worksheet, so we are not necessarily restricted to a single values. But we do end up with value(s) in the range in the LHS. We do the same calculation as if we ended up with a formula in the cell. But it’s a false statement, often given when explaining what Evaluate(" ") is doing, to say it fundamentally does a mathematical calculation, gets a value(s) or fundamentally "evaluates". It can "do formulas"
Ref
https://eileenslounge.com/viewtopic.php?p=280997#p280997
https://www.myonlinetraininghub.com/excel-functions-that-return-references#comment-84892
DocAElstein
03-13-2024, 04:13 PM
Quotes in VBA
Rem 2 Puts formula in cell(Quotes in VBA )
' 2a
At this point we see for the first time the confusing world of quotes in VBA, and Excel in general.
In Excel spreadsheets, within a formula, we would enclose text we wanted to appear as text, in a quote pair, as this signalises to Excel that we want a literal text, rather than that the text is a name, function or some other specific thing that the text represents in Spreadsheet syntax.
Quotes in VBA
For VBA it is the same: In other words, what is within a quote, will not be regarded directly as part of the coding, but rather refers to some actual text that will be used in some way, depending on what the coding associated with it is about. For us here, the text within the quotes is the text that we finally want to see.
Working in VBA, ( or in a spreadsheet cell), to produce a string that we want to show a quote, becomes problematic. It is not clear if anybody really knows how and why we can get over this problem. There is no real documentation, although you might find the simple rile or explanation along the lines of…. Strings in VBA are delimited with quotation marks. If you want to include quotation marks in your string, you need to double them. Otherwise, the VBA compiler will not recognize that they should not end the string….
Well, that may be a correct statement, but I am not sure if that is a good explanation and whether it works by design or accident.
For me the following ideas helps to remember and possibly have an explanation or at least a theory that can explain the results and behaviour: It’s not too distant or different to that statement, it is an idea that helps me to remember, and possibly an
explanation:
The syntax will not allow a single quote within a quote pair, as the complier requires a pair. The syntax of VBA coding would also understandably find these strange.
__________ = "___ "____"___ "
__________ = "xyz"____"xyz"
But consider what might happen when we bring the inner quote pair together
__________ = "xyz""xyz"
I am thinking that we may have some sort of strange dynamic equilibrium situation, whereby simultaneously the quote pair syntax is satisfied and we have two joined pairs of text, ( "intimately joined"), which VBA sees on the compile as something like this
xy"xyz""
xyzxy""xyz"
, but because of this intimacy of the join, the position of the two inner quotes appears in the same place, meaning that the string is joined,- a quote may be defined twice, but in the same place, resulting in the final string as seen by VBA as
xyzxyz"xyz
Another way perhaps for thinking about is that they are actually a bit further than intimately joined, a character is entwined. By definition, the actual final literal string starts or stops on the other side of the quote, either after or before the quote. If you look at some of those coloured sketches you can perhaps imagine that the stop and start of the two literal bits of literal text is in the same place, which further joins them by two quotes merged into one.
Using Debug.Print to aid in string construction
Even with a good understanding of quotes in VBA, it is very easy to make a mistake. This general rule can help:
Printing out the string you have attempted to construct in the immediate window, will show it as VBA sees it after compile, and shows what VBA, after compile, will be trying to put in a cell via a code line like
Let Range("C1") = The string you have constructed
So, that string shown in the immediate window must be syntaxly kosher for an Excel cell, in otherwords it must look like the string as you would manually write it in a cell. So for putting a formula in a cell, something like this would be OK
= "a" & "b"
, resulting in the value
ab
showing in the cell, ( and in the formula bar you will see = "a" & "b" , just as in the immediate window )
On the other hand, something like these showing for a Debug.Print of your constructed string, would likely error when used
= "a" & b"
= "a" & ""b"
= ""a"" & "b"
So finally, in ' 2a we have a string construction that we are happy with to put a formula in a cell which will be the Excel spreadsheet formula, ="a"&Char(10)&Char(13)&"b" , as indeed we see both in the formula Bar, and in the immediate window if using
Debug.Print "=" & """a""" & "&" & "Char(13)&Char(10)" & "&" & """b""" & ""
To briefly explain that final string construction in words
______ "=" & """a""" & "&" & "Char(13)&Char(10)" & "&" & """b""" & ""
The outer most quotes are those always required in VBA to signalise that we are giving literal text.
Within those outer quotes, in VBA coding we may build up the string from further string elements. (The string can also be built up from VBA things returning strings or numbers, as we will do in the next post. Here we are only using other string elements), The syntax of VBA will require further enclosing quotes for every further string elements, and furthermore, VBA syntax requires an ampersand symbol, _ & _ , to join these strings, thus
______ "__" & "¬¬¬¬____" & "asskasasaf"
In green is the literal text, as we would write it in a cell.
Excel spreadsheet syntax requires in the final written cell formula text ampersands, & , which will be here literal text, hence must be enclosed with VBA quote pairs, thus
"&"
Finally, the Excel spreadsheet syntax requires that a literal text such as the character a, must be enclosed in the cell in quotes, but as we discussed in quotes in VBA something like this would error , ""a"" , we require to effectively double quote where we want a final single quote in the final string , """a"""
The final value in the cell would be
a
b
We have there 4 characters, pseudo like, (and it’s a bit subjective/ arbitrary of me, how I show them here in this pseudo form, just for explanation purposes: )
a vbCr
vbLf b
Some final minor notes:
_ If we are in in non English Excel, as I am, we can type either of these in the Immediate window to get the English syntax.
? range("C1").Formula
Debug.Print range("C1").Formula
_ Once we have the final string, we can often simplify, mainly by removing some VBA joining bits, since they are redundant when linking only literal text – the text can simply appear together.
______ "=""a""&Char(13)&Char(10)&""b"""
However, from experience I would only do this, if ever, at a final stage, since the careful explicit constructions are usually easier to build up and debug. Indeed, with hindsight, I might separate all the final cell texts of "a" and "b", as shown within the VBA construction, into the 3 characters of a quote, an a , and a final quote, just so as to make them clearly correspond to the explanations given of the quotes in VBA
______ "=" & """" & "a" & """" & "&" & "Char(13)&Char(10)" & "&" & """" & "b" & """" & ""
In words, just as you would write in the cell ,
=
and
a quote "
and
a
and
a quote "
and
a ampersand &
and
a quote "
and
the two joined text (functions), Char(13)&Char(10)
and
a ampersand &
and
a quote "
and
b
and
a quote "
https://i.postimg.cc/j2SJH7tY/a-CHAR-13-CHAR-10-b.jpg
5795 https://i.postimg.cc/k6L49D2T/a-CHAR-13-CHAR-10-b.jpg (https://postimg.cc/k6L49D2T)
https://i.postimg.cc/j2SJH7tY/a-CHAR-13-CHAR-10-b.jpg (https://postimages.org/)
So we have done the background revision and can move on in the next post to the problem / issues with vbCr & vbLf in formulas and Evaluate(" "), well almost
DocAElstein
03-20-2024, 04:38 PM
this is post #597
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24087&viewfull=1#post24087
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24087&viewfull=1#post24087
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page60#post24087
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page60#post24087
We are not quite finished
A Final Evaluate full. Text. But it does a formula,
You should be confused at this point. If you aren’t, then you are not normal. We are putting text in a cell. The final step is to complete it with Evaluate, for what reason I have long since forgotten myself.
A recap is perhaps useful:
We figured out a tricky syntax, and in doing so came close finally to conclusions leading to an understanding of Evaluate (" ") that probably no one has…... Office is an old program, in software age, and has had an incredible number of fixes. I doubt anyone at Microsoft has any idea of the entire suite's programming. I doubt anyone at Microsoft has a handle on the coding…. (https://eileenslounge.com/viewtopic.php?p=317257#p317257)
We stated this by looking at putting text in cells. We were also messing with Evaluate (" ")
We spoke about a flexible = that allows a formula to be done, and in a cell, if the result is to be out in a cell, then just the value will be put in.
Our final code line so far considered was this .._
Range("E4") = Evaluate("a" & Evaluate("""" & vbCr & vbLf & """") & "b") ' In Cell we see #WERT! - IT APPEARS TO BE RETURNING ERROR 2015
_.. and it errored , (as did all our Evaluate attempts)
We had concentrated on the Evaluate("""" & vbCr & vbLf & """") stuff. But I think we can see clearly from all our discussions and in particular to the initial stab at some conclusions, that we need to have in the Put in the cell, Debug.Print seen string a quote pair around the a and the b
Let's say that again a bit differently: Currently we have what we could call the Evaluate(" or VBA code line required quotes around it. This would be like Excel trying to recognise a Name or meaning to
a
, and failing that, Evaluate(" ") tries to see if doing
=a
, gives soimethi8ng sensible. Unless you specifically have given that character, a , some meaning in Excel , that will error.
The oint that needs to be remembered over and over again is that in this situation, we can consider Evaluate(" ") to be trying to get what we finally want, via a formula in a cell, but we won’t fonally get a formula if its successful: We will get the actual final result. In other words, in this example a cell would want to see
="a"
So… what to do
And this is the crux actually, of what started this page in order to get vbCr & vbLf to do what we wanted: In that final Evaluate string we need to do something to make the a and the b be seen to be enclosed in quotes. That requires a double quote per quote you finally want to see.
Let’s do that in a separate coding, Sub CarriageReturnLineFeedExcelVBAEvaluateTextFormula( )
Sub CarriageReturnLineFeedExcelVBAEvaluateTextFormula( ) ' https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24087&viewfull=1#post24087
On Error GoTo Bed
' A few things to make things in the demo look closer to what they are
Call TidyCellView ' When experimenting it may be a good idea to occaisionally do this again, as Excel occaisionally may change things if it geusses incorrrectly what we want to see
Debug.Print
' 1f Finally
Debug.Print "Rem 1f": Let Range("F1") = "Rem 1f" & vbLf & _
"Evaluate(" & """""""" & "a" & """""""" & ")" & " & " & " Evaluate" & "(" & """" & """" & """" & """" & " " & "&" & " vbCr " & "&" & " vbLf " & "&" & " " & """" & """" & """" & """" & ")" & " " & " & " & "Evaluate(" & """""""" & "b" & """""""" & ")"
Let Range("F1").Characters(Start:=1, Length:=6).Font.Color = -11489280: Let Range("F1").Characters(Start:=7, Length:=78).Font.ColorIndex = xlAutomatic
Debug.Print Evaluate("""" & "a" & """") & Evaluate("""" & vbCr & vbLf & """") & Evaluate("""" & "b" & """")
Let Range("F4") = Evaluate("""" & "a" & """") & Evaluate("""" & vbCr & vbLf & """") & Evaluate("""" & "b" & """")
Debug.Print
Debug.Print
Exit Sub
Bed:
Debug.Print Err.Number
Debug.Print Err.Description
Resume Next
End Sub
What have we done.
Let’s put into words what we have done, as it will help in the next post sections, when we do putting formulas into cells with Evaluate("")
We created a full string for VBA equivalent to
"a" & vbCr & vbLf & "b"
"a" was got from this Evaluate("""" & "a" & """")
vbCr & vbLf was got from this Evaluate("""" & vbCr & vbLf & """")
"b" was got from this Evaluate("""" & "b" & """")
But, and this is important,
The three Evaluates effectively did these three things:
It got the result as if we typed in a cell ="a" which resulted in a
It got the result as if we typed in a cell ="the character for a carriage return" & "the character for a carriage return" which resulted in a visible line break, or second line, or however you personally describe that
It got the result as if we typed in a cell ="b" which resulted in b
Evaluate got us the 3 results from a formula, as if I typed the formula in a cell in a cell
https://i.postimg.cc/vmSF6JBH/Column-F-results.jpg
5827 https://i.postimg.cc/hJx3k3TH/Column-F-results.jpg (https://postimg.cc/hJx3k3TH)
https://i.postimg.cc/vmSF6JBH/Column-F-results.jpg (https://postimages.org/)
DocAElstein
03-23-2024, 11:33 PM
this is post #598
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24089&viewfull=1#post24089
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24089&viewfull=1#post24089
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page60#post24089
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page60#post24089
Rem 2 Put formula in cell (Sub CarriageReturnLineFeedExcelVBAFormula() )
Having forced myself into going back to the basics, and getting a more deeper understanding of Evaluate(" ") , the problems in some syntax in putting formulas into a cell , or finding text things via an excel formula in Evaluate(" ") , which caused the excursion of this page , is easy to do, and sure to get it, as long as we are patient and cautious.
So armed with some knowledge of constructing the necessary strings, and some initial attempt at a a Results Summary Conclusion attempt (https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page60#post24055)we move on to get the same value in a cell as previously, but from a formula, that is to say, taking Evaluate(" ") string constructs that one step further to actually put a formula in a cell …. pseudo
Put in the cell = a formula looking like , ="Hello"
, using
Put in the cell = Evaluate( string construct to actually give a formula, not the result from it )
Note , of course, you will still see the value result in the cell, but an indication that we actually put on a formula, rather than a value, should be seen in the formula bar, just as if we manually typed the formula in, ( assuming default Excel settings )
https://i.postimg.cc/9Mf54ycw/Formula-in-cell-to-display-text.jpg
5829 https://i.postimg.cc/McgrNMMz/Formula-in-cell-to-display-text.jpg (https://postimg.cc/McgrNMMz)
https://i.postimg.cc/9Mf54ycw/Formula-in-cell-to-display-text.jpg (https://postimages.org/)
An extra quote, or two, and stuff
Having battled out enough with the basics in the last few posts, it’s actually not so difficult from now on
Points to note
_1) literal text in a cell, needs to be put in initially, "in the first place" as it were, in quotes in the string construct for evaluate just to prevent Evaluate(" ") trying to interpret the text as some particular Excel thing. So far we did this explicitly like this
Evaluate("""" & "Mytext" & """")
, which you would have to do if your text was in a variable , - example if your text was in a string variable, strText, then you would need to do this
Evaluate("""" & strText & """")
, or we could consder the new line pair things we have been considering as variables, and as such also need to do like
Evaluate("""" & vbCr & vbLf & """")
For actual text, this would be the same
Evaluate("""Mytext""")
, but I would recommend always being explicit until maybe you have finished.
Based on the results and attempted explanations of Evaluate(" ") so far generally, and with a bit of hindsight again, I might have a go at a slightly modified explanation of Evaluate(" ")
If you or I type an = at the start of putting something in a cell, then that is a significant thing that calls into action deep Office innards coding which I expect is either the same, or in some way strongly related to, or very similar to, the coding that gets set off by Evaluate(" "). There will be similarities therefore in the result, where I am using the word result in its broadest sense here: Just one example of this similarity is that it could be that a text or number appearing in the cell would be that which would appear in a variable, Ex if you did something like this
Ex = Evaluate("What you put in a cell after typing in a = at the start")
But that is just part of the story, perhaps what is often given as the simplifies version of what Evaluate(" ") is about.
More fully, the string what VBA "sees" will need to be a syntax, or named thing, that Excel recognises, and its always very good practice when constructing the string in Evaluate, ( strEval, where strEval is like here, Evaluate(strEval) ) , to check what VBA sees via Debug.Print strEval
I expect there may be a priority to the order that things are done.
Calling something out
First, a reference to an object or something will have a varied effect. Maybe we could refer this to calling it out, like shouting at someone to call them to attention. It may make them do something or get them there, ready. We sometimes hear of "exposing an interface" having a similar effect to running it. I like the sound of calling it out
Do a formula to do something (even a formula!)
This is easy to get mislead and confused. If a string construct, what VBA finally "sees", can be recognised as a syntax that Excel would be happy with in a cell, A formula, then the result that would be obtained of that string with an = in front of it, in a cell, is what Evaluate(" ") will try to return. At a stretch of the imagination, this could be regarded as calling out an imaginary cell, by its name, its cell reference, where the imaginary cell has that formula in it. This should perhaps spark off someone smarter to get excited and tell me about kicking off an Excel4 macro somehow. Just now it’s a leap too far for my brain. But I think the idea is potentially sound
Having got to this level of understanding, maybe we can do close to anything , within reason, even … put a formula in a cell
So let’s have a go. Introduction to formula in a cell
Backwards working understand, to easier perhaps is this. (This is perhaps easier to understand, working backwards.)
For example , I want this formula to effectively be put in a cell ,
="Hello"
, which will mean that I see Hello in the cell, and in the formula bar I will see ="Hello"
If I was using VBA to put that formula in a cell, I would need to construct the VBA string context for that, which would be like
Range("A10") = "=""Hello"""
To achieve that from a code line like ,
Range("A10") = Evaluate("")
, then Evaluate("") will need to return "=""Hello"""
So far we have learnt that for returning "Hello" in VBA , the RHS == Evaluate("") , would need to look like this
Evaluate("""" & "Hello" & """")
In simplified terms, we can say that in that construction , the 4 quotes, """" is getting us a single quote in that "Hello" in VBA
So a simplified logic perhaps tells us we need a few more of the 4 quotes, """" bits, ( as well as an = somewhere )
Just looking carefully , and applying the simple logic tells us we want : a quote; a =; 2 quotes; the text Hello ; and finally 3 quotes.
So perhaps we want this VBA context string
Evaluate(VBA context string)
"""" & "=" & """" & """" & "Hello" & """" & """" & """"
This next simple coding shows the construction clearly breaking down each required string bit
Sub CallOutTextInCellFormula() ' https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24089&viewfull=1#post24089
' Effectively put ="Hello" in a cell , which will mean that I see in the cell Hello and in the formula bar ="Hello"
Let Range("A10") = "=""Hello"""
' we need from Evaluate(" ") a quote, a =, 2 quotes, Hello , and finally 3 quotes
' " = " " Hello " " "
Let Range("A10") = Evaluate("""" & "=" & """" & """" & "Hello" & """" & """" & """")
End Sub
Having got this far, at the final stage, we can simplify quite easily, if we wish to. The thing here to remember is that the & is only required to
_ link or glue variables or other VBA things to each other
or _ to link or glue variables or other VBA things to text
It is not required to link or glue text to text.
This means that bits like " & " can be removed
Do that with our last example, and you end up with this rather impressive looking beautiful thing
"""=""""Hello"""""""
Just to confuse or impress a little further, we have noted previously the somewhat "flexible" = that Evaluate(" ") seems to posses. There is no exception here, so we could add that last bit of apparent mystical magicness to that last string construction
"=""=""""Hello"""""""
Sub CallOutTextInCellFormula() ' https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24089&viewfull=1#post24089
' Effectively put ="Hello" in a cell , which will mean that I see in the cell Hello and in the formula bar ="Hello"
Let Range("A10") = "=""Hello"""
' we need from Evaluate(" ") a quote, a =, 2 quotes, Hello , and finally 3 quotes
' " = " " Hello " " "
Let Range("A10") = Evaluate("""" & "=" & """" & """" & "Hello" & """" & """" & """")
'
' simplified
Let Range("A10") = Evaluate("""=""""Hello""""""")
Let Range("A10") = Evaluate("=""=""""Hello""""""")
End Sub
_._________________
&
A small reminder about the & in string context both In VBA and Excel spreadsheet syntax.
As we seen already in a coupe of places ( https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24083&viewfull=1#post24083
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24050&viewfull=1#post24050 ) we have this same "gluing together" thing in both Excel and VBA.
If the formula we are trying finally to put in a cell has in Excel a & , then that & will effectively be another bit of text to add.
Note also in the following example to get like a formula ="Hello"&" You" we cannot rely on Evaluate(" ") to somehow return us VBA connecting / gluing & bits , so we must do some simplification in such example cases.
Sub CallOutTextInCellFormula() ' https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24089&viewfull=1#post24089
' Effectively put ="Hello" in a cell , which will mean that I see in the cell Hello and in the formula bar ="Hello"
Let Range("A10") = "=""Hello"""
' we need from Evaluate(" ") : a quote; a =; 2 quotes; Hello ; and finally 3 quotes
' " = " " Hello " " "
Let Range("A10") = Evaluate("""" & "=" & """" & """" & "Hello" & """" & """" & """")
'
' simplified
Let Range("A10") = Evaluate("""=""""Hello""""""")
Let Range("A10") = Evaluate("=""=""""Hello""""""")
' Put ="Hello"& "You" in a cell
Let Range("A11") = "=""Hello""" & "&" & """ You"""
' Evaluate will not be ablk to return the two connecting/ gluing VBA things " & " so we will need to be at the simplified level
Let Range("A11") = "=""Hello""&"" You"""
' we need from Evaluate(" ") : a quote; a =; 2 quotes; Hello ; 2 quotes ; the & ; 2 quotes ; You ; and finally 3 quotes
Let Range("A11") = Evaluate("""" & "=" & """" & """" & "Hello" & """" & """" & "&" & """" & """" & " You" & """" & """" & """")
' simplified
Let Range("A11") = Evaluate("""=""""Hello""""&"""" You""""""")
End Sub
DocAElstein
04-17-2024, 06:49 PM
this is post #599
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24089&viewfull=1#post24132
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24132&viewfull=1#post24132
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page60#post24132
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page60#post24132
Put Formulas in cells, with Evaluate(" ") , or use them in Evaluate Range type solutions if they are involved with new line Characters
The original issues that sparked off this page, can be dealt with, or rather can be almost forgotten and / or don’t occur, as we now have a much better in depth understanding of the required string constructions, so can go directly to them, armed with our new knowledge of what fundamentally the Evaluate(" ") is /does
' 2a CHAR(13)&CHAR(10)
CHAR(13)&CHAR(10) is recognised Excel syntax. The Characters of a and b are not
VBA wants to see the following string in order to put the formula = "a" & CHAR(13) & CHAR(10) & "b" into the cell
"=""a""&CHAR(13)&CHAR(10)&""b"""
In other words, if I wanted to use VBA to put this formula in cell B10,
= "a" & CHAR(13) & CHAR(10) & "b"
, ( as an alternative to me physically typing this in ), then I would need a code line like
Range("B10") = "=""a""&CHAR(13)&CHAR(10)&""b"""
So producing all those bits on the RHS using Evaluate(" ") on the RHS requires carefully producing each of those 18 things from what we have learned is how they need to look like within the Evaluate(" ") string:-
"""" & "=" & """" & """" & "a" & """" & """" & "&" & "CHAR (13)&CHAR(10)" & "&" & """" & """" & "b" & """" & """" & """" With the previous knowledge, it’s fairly straight forward.
Here saying it again. In words what we have done is: We consider the string that VBA wants to have , in its simplest form. ( It must be in the simplest form without any of the VBA " & " bits, since Evaluate(" ") in this use if it is only going to return to us a simple string, not a code line. By the same reasoning the Evaluate(" ") won’t give any other VBA things like variables and functions, so the " & " is not needed anyway. – ( It would be needed to link string text to other things like VBA variables and functions and formulas, in which case it would have this sort of form , missing one of the quotes, __ "words " & VBA stuff & " other words" )
We then make the string for evaluate, strEval . We do this by consigöring each Character in turn of this string we need in VBA, "=""a""&CHAR(13)&CHAR(10)&""b""" – Let’s open that out just to make it easier to see all those 18 bits
" = " " a " " & CHAR(13)&CHAR(10) & " " b " " " ' For VBA
For each of the 18 things there, we know the equivalent to have inside Evaluate(" ")
Each of those is then joined by a " & "
Here is that working result again
"""" & "=" & """" & """" & "a" & """" & """" & "&" & "CHAR(13)&CHAR(10)" & "&" & """" & """" & "b" & """" & """" & """"
What finally is returned from the RHS and seen by VBA and then put in the cell is, as we would physically write it
="a"&CHAR(13)&CHAR(10)&"b"
A final simplification can be made to the evaluate string by removing all the " & " bits
_"""=""""a""""&CHAR(13)&CHAR(10)&""""b"""""""
or **
"=""=""""a""""&CHAR(13)&CHAR(10)&""""b"""""""
One last things that will be useful to compare with the over next section. ' 2b(ii) , will be
the Debug.Print of the string to be used in Evaluate(" ") strEval , _____ and the formula finally put in the cell and seen in the formula bar
__ "=""a""&CHAR(13)&CHAR(10)&""b""" ________ ="a"&CHAR(13)&CHAR(10)&"b"
' 2b vbCr & vbLf
' 2b(i)
We might want to go back a bit to some of the conclusion attempts here https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24055&viewfull=1#post24055
We said along the lines of that vbCr & vbLf was actually a text of two Characters, not much different to like xy. Even if we say that we know that vbCr & vbLf is a VBA text construct thing, used when building up a string in VBA, then that still does not help us to get anything useful out of Evaluate(vbCr & vbLf), (and this does nothing at all for us either Evaluate("" & vbCr & vbLf & "") )
This is a consequence of our better understanding of Evaluate(" ") in that it calls out an exposition of the underlying functionality, of the fundamental Excel object to which is named. This strange looking constant, vbCr & vbLf makes no sense to Excel.
Doing this Evaluate("""" & "a" & """") gives us the same results as putting ="""" & "a" & """" in a cell and the result from that world be ,
"a"
, ( regarding the extra = see ** ) That "a" is the required string to present in VBA on the RHS to put an a in a cell
To this consideration of the character a is a parallel to the Characters vbCr & vbLf - Doing this Evaluate("""" & vbCr & vbLf & """") gives us the same results as pseudo putting ="""" & "NewLineCharacters" & """" in a cell, although that pseudo syntax, NewLineCharacters , is not recognised, but the underlying shared innards working does the same, and the result from that world be, … well a bit difficult to show, but something pseudo like ,
"
_"
That is effectively the required string to present in VBA on the RHS to put those two Characters in a cell.
' 2b(ii) vbCr & vbLf
What perhaps the last section, ' 2b(i) , has told us, or as interpreted to be saying , is that the two VBA things, vbCr & vbLf return in a string construct in VBA "NewLineCharacters" , so that will be fine to apply to , (put in ) , a cell to on the RHS of a code line like pseudo ,
Range("xxx") = "NewLineCharacters"
, so the same as
Range("xxx") = vbCr & vbLf
, which will effectively put in two "invisible" characters, (although if you fiddle with the cell or formula bar format and size, select the cell or formula bar and move around with the arrow keys, then you may see the cursor moving giving the indication of something there )
So here we go, very similar to ' 2a except we consider that rather than having available a recognised Excel syntax/Name CHAR(13)&CHAR(10) we have something which we can consider pseudo like an xy or a or b literal character(s) , and that is pseudo like NewLineCharacters
The Characters of a and our pseudo NewLineCharacters and b are not recognised Excel syntax/names
VBA wants to see the following string in order to put the formula = "a" & "NewLineCharacters" & "b" into the cell
"=""a""&""NewLineCharacters""&""b"""
So producing all those bits from Evaluate(" ") requires carefully producing each of those Characters
"""" & "=" & """" & """" & "a" & """" & """" & "&" & """" & """" & "NewLineCharacters" & """" & """" & "&" & """" & """" & "b" & """" & """" & """"
"""" & "=" & """" & """" & "a" & """" & """" & "&" & """" & """" & vbCr & vbLf & """" & """" & "&" & """" & """" & "b" & """" & """" & """"
What finally is returned from the RHS and seen by VBA and then put in the cell is, as we would physically write it, ( if we could, - remember we have a pseudo characters, NewLineCharacters
="a"&"NewLineCharacters"&"b"
A final simplification can be made to the evaluate string by removing all the " & " bits
"""=""""a""""&""""" & vbCr & vbLf & """""&""""b"""""""
or
"=""=""""a""""&""""" & vbCr & vbLf & """""&""""b"""""""
One last thing interesting to compare with the first formula section. ' 2a , will be
the Debug.Print of the string to be used in Evaluate(" ") strEval
, and the formula finally put in the cell and seen in the formula bar
"=""a""&""
""&""b"""
="a"&"
"&"b"
A subtle difference perhaps, is that we are not passing a Excel known name / syntax that will do the new line, but rather perhaps the actual characters. Not sure of the significance if that, if any, but there may be some hidden revaluations in it at some later date….
Edit. Actually I have found a few remarkable things come out when including some of the "invisible" characters, as well as other VBA things, in the string construction. But based on my previous experience of revealing some of my lesser controversial discoveries I have serious decided to not openly discus them until/ if I become very rich and famous so that I can afford a small army of the best body guards. I am happy to say that here as I am sure most people won’t believe a word of it yet, so I am fairly safe.
(** Toleranceual redundancy , akin to adding the obstruction in a path of an open door, that door being the one closed on a cell and opened by the inclusion of an = at the first textual position thereof . )
DocAElstein
04-17-2024, 06:49 PM
this is post #600
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24089&viewfull=1#post24133
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24133&viewfull=1#post24133
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page60#post24133
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page60#post24133
Evaluate(" ")
This is often seen to be allowing Excel spreadsheet things to be done in VBA, and therefore a simplified explanation and some Blogs on Evaluate(" ") , the Evaluate method, will concentrate on this feature of it. That is not necessarily misleading, and is not a bad simplified start point.
After a lot of head breaking , I think I have a statement(s)/ ideas from which I am happy to expand and add flesh to in order to explain away both the accepted conventional things done with it, and to some extent the more advanced interesting and not always accepted unconventional things I have done, and also some more recent little discoveries, (which because of previous reactions I am never going to make public until when/if I become very rich and famous, so that I can afford a small army of the best body guards)
Here we go , it's like this:
This would be my entry in a simple dictionary, or the very first bit in an explanation:
___Evaluate _ (Callout an Excel object by referring thereto)
Call out is in the sense of bringing it to attention via some sort of reference string or name , and this is sometimes referred to as exposing an interface. A Run or a Call of something are a similar thing. We often experience that using a recognised text will make something happen . An Excel in built function and a User Defined Function, (UDF), can reasonably be considered to be similar things, even an Excel object, if Object is used in its very broadest sense, as is reasonably acceptable and certainly not conflicting with the somewhat bodged together form of apparent object orientated programming that VBA is. Don’t be confused that I went over to VBA there - what I am suggesting there is that the wrapper for the function coding has the name for referral to be Called of the routine name, which is recognised by Excel – in other words the name of a UDF is recognised by Excel, - as most of us will know, that is true of a Public Function in a normal code module, which is what a UDF is.
DocAElstein
04-17-2024, 06:52 PM
This is post https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page61#post24134
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page61#post24134
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24134&viewfull=1#post24134
https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24134&viewfull=1#post24134
Some notes in support of this main forum post
https://eileenslounge.com/viewtopic.php?p=316419#p316419
Good Lord, WTF is this… a punishment, I think
Sub M_snb() ' https://eileenslounge.com/viewtopic.php?p=316419#p316419
Dim c00 As String
c00 = "Mon, 04 Mrz 2024 08:48:08 GMT"
MsgBox CDate(Replace(Mid(c00, 6, 20), Mid(c00, 8, 5), "-" & Application.Match(Mid(c00, 9, 3), [transpose(text(30*row(1:12),"[$-407]mmm"))], 0) & "-"))
End Sub
Let’s first break it down / open it up a little bit
CDate(Replace(Mid(c00, 6, 20), Mid(c00, 8, 5), "-" & Application.Match(Mid(c00, 9, 3), [transpose(text(30*row(1:12),"[$-407]mmm"))], 0) & "-"))
CDate(
Replace(Mid(c00, 6, 20), Mid(c00, 8, 5), "-" & Application.Match(Mid(c00, 9, 3), [transpose(text(30*row(1:12),"[$-407]mmm"))], 0) & "-")
)
Replace(
Mid(c00, 6, 20), Mid(c00, 8, 5), "-" & Application.Match(Mid(c00, 9, 3), [transpose(text(30*row(1:12),"[$-407]mmm"))], 0) & "-"
Expression , find , replace , start, count, compare
)
Replace(expression, find, replace, start, count, compare ) https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/replace-function
So let’s look at this first Application.Match(Mid(c00, 9, 3), [transpose(text(30*row(1:12),"[$-407]mmm"))], 0)
The array, [transpose(text(30*row(1:12),"[$-407]mmm"))]
The final thing it ends up with is a 1 D array , ( as we need for the .Match ) , which looks like
{"Jan", "Feb", "Mrz", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"}
The main thing there is the Excel TEXT function, which tries to return a text out of …._
_.... = TEXT( a number , the second argument is some recognised format )
For now I will have to believe that [$-407] means German dates and the mmm is likely what it always is in these date things: The month in 3 letters. The numbers generated are { 30, 60, 90 …. 360 }, so that is a nice way to get a day number for each month, so like we finally have, as example the second array element gives pseudo like
TEXT(60, [$-407]) = "Feb"
I might do the array a bit differently…
Let vTemp = Evaluate("30*row(1:12)") ' {30; 60; 90; 120; 150; 180; 210; 240; 270; 300; 330; "360"}
Let vTemp = Evaluate("text(30*row(1:12),""[$-407]mmm"")") ' "Jan"
Let vTemp = [text(30*row(1:12),"[$-407]mmm")] ' "Jan"
Let vTemp = Evaluate("if({1},text(30*row(1:12),""[$-407]mmm""))") ' {"Jan"; "Feb"; "Mrz"; "Apr"; "Mai"; "Jun"; "Jul"; "Aug"; "Sep"; "Okt"; "Nov"; "Dez"}
Let vTemp = [IF({1},text(30*row(1:12),"[$-407]mmm"))] ' {"Jan"; "Feb"; "Mrz"; "Apr"; "Mai"; "Jun"; "Jul"; "Aug"; "Sep"; "Okt"; "Nov"; "Dez"}
Let vTemp = [TEXT(30*COLUMN(A:L),"[$-407]mmm")] ' "Jan"
Let vTemp = Evaluate("TEXT(30*COLUMN(A:L),""[$-407]mmm"")") ' "Jan"
Let vTemp = [IF({1},TEXT(30*COLUMN(A:L),"[$-407]mmm"))] ' {"Jan", "Feb", "Mrz", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"}
Let vTemp = Evaluate("IF({1},TEXT(30*COLUMN(A:L),""[$-407]mmm""))") ' {"Jan", "Feb", "Mrz", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"}
' So what we got is a 1 D array of the months as Excel has them for Germany
Evaluate("IF({1},TEXT(30*COLUMN(A:L),""[$-407]mmm""))")
DocAElstein
04-17-2024, 11:13 PM
From last post ….
We got the 1 D array for the .Match thing,
Application.Match(Mid(c00, 9, 3), the 1 D array , 0)
Application.Match(Mid(c00, 9, 3), {" Jan", "Feb", "Mrz", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez" } , 0)
The Mid(c00, 9, 3) gets us the 3 letter month given in the original string date ( from the Web apparently (https://eileenslounge.com/viewtopic.php?f=30&t=40899))
So this gives us a position number which will also be the number of the date, starting at 1 for January.
For out data example, "Mon, 04 Mrz 2024 08:48:08 GMT", then Mid(c00, 9, 3) is Mrz , so we end up with 3
The Replace(
We do the Replace on just part of the original string , ( this is the original staring )Mon, 04 Mrz 2024 08:48:08 GMT
We do the Replace on just the Mid(c00, 6, 20) bit, which is 04 Mrz 2024 08:48:08
We replace the Mid(c00, 8, 5) bit, and that bit is _ Mrz _ ( five characters there – a trailing and leading space on the Mrz )
We end up with
04-3-2024 08:48:08
For the OP something else would have done, but that looks nice, it looks like a nice time date type form that things Excel/ VBA might recognise. So I am happy with that :)
At this stage, I am guessing that that will be recognised by Excel/ VBA as a date time thing. Sure enough it is, ( and in this case it does not seem to try and do anything to swap the day and month number around)
I end up with
04-03-2024 08:48:08
So it has added a leading 0 before the 3, but as said (on my Vista machine with settings of mm-dd-yyyy), it did not try to swap the 03 and 04 around
A few other remarks
Rem '2b
We probably do not need the CDate, - if a variable is declared as Date, then assigning the RHS to it will effectively do a similar convert to date.
Rem '2c
For this sort of thing, a / and a – seem to have a similar effect
Here is the coding so far
Sub Mrz_snb() ' https://eileenslounge.com/viewtopic.php?p=316419#p316419
Rem 0 Somne stuff to help show the sort of date format is in the system
Dim XlToday As Date, VBAToday As Date
Let XlToday = Evaluate("=Today()"): Let VBAToday = Date
Debug.Print Application.OperatingSystem & " XLToday " & XlToday; " VBAToday " & VBAToday
Dim Valory As String, vTemp As Variant, c00 As Variant
Let Valory = "Mon, 04 Mrz 2024 08:48:08 GMT": c00 = "Mon, 04 Mrz 2024 08:48:08 GMT"
Rem https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)/page61#post24134
Let vTemp = Evaluate("30*row(1:12)") ' {30; 60; 90; 120; 150; 180; 210; 240; 270; 300; 330; "360"}
Let vTemp = Evaluate("text(30*row(1:12),""[$-407]mmm"")") ' "Jan"
Let vTemp = [text(30*row(1:12),"[$-407]mmm")] ' "Jan"
Let vTemp = Evaluate("if({1},text(30*row(1:12),""[$-407]mmm""))") ' {"Jan"; "Feb"; "Mrz"; "Apr"; "Mai"; "Jun"; "Jul"; "Aug"; "Sep"; "Okt"; "Nov"; "Dez"}
Let vTemp = [IF({1},text(30*row(1:12),"[$-407]mmm"))] ' {"Jan"; "Feb"; "Mrz"; "Apr"; "Mai"; "Jun"; "Jul"; "Aug"; "Sep"; "Okt"; "Nov"; "Dez"}
Let vTemp = [TEXT(30*COLUMN(A:L),"[$-407]mmm")] ' "Jan"
Let vTemp = Evaluate("TEXT(30*COLUMN(A:L),""[$-407]mmm"")") ' "Jan"
Let vTemp = [IF({1},TEXT(30*COLUMN(A:L),"[$-407]mmm"))] ' {"Jan", "Feb", "Mrz", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"}
Let vTemp = Evaluate("IF({1},TEXT(30*COLUMN(A:L),""[$-407]mmm""))") ' {"Jan", "Feb", "Mrz", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"}
' So what we got is a 1 D array of the months as Excel has them for Germany
Let vTemp = Application.Match(Mid(c00, 9, 3), vTemp, 0) ' 3
Let vTemp = Replace(Mid(c00, 6, 20), Mid(c00, 8, 5), "-" & vTemp & "-") ' 04-3-2024 08:48:08
Rem https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=24135&viewfull=1#post24135
Debug.Print CDate(vTemp) ' KB 04-03-2024 08:48:08 SSD2 04.03.2024 08:48:08
Let vTemp = CDate(vTemp)
Debug.Print vTemp ' KB 04-03-2024 08:48:08 SSD2 04.03.2024 08:48:08
' 2b
Dim Dte As Date
Let Dte = vTemp: Debug.Print Dte
Debug.Print CDate(Replace(Mid(c00, 6, 20), Mid(c00, 8, 5), "-" & Application.Match(Mid(c00, 9, 3), [transpose(text(30*row(1:12),"[$-407]mmm"))], 0) & "-"))
' 2c
Let vTemp = Evaluate("IF({1},TEXT(30*COLUMN(A:L),""[$-407]mmm""))") ' {"Jan", "Feb", "Mrz", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"}
Let vTemp = Application.Match(Mid(c00, 9, 3), vTemp, 0) ' 3
Let vTemp = Replace(Mid(c00, 6, 20), Mid(c00, 8, 5), "/" & vTemp & "/") ' 04/3/2024 08:48:08
Debug.Print CDate(vTemp) ' KB 04-03-2024 08:48:08 SSD2 04.03.2024 08:48:08
'Dte As Date
Let Dte = vTemp: Debug.Print Dte ' KB 04-03-2024 08:48:08 SSD2 04.03.2024 08:48:08
End Sub
'
' KB Vista
' Windows (32-bit) NT 6.00 XLToday 04-17-2024 VBAToday 04-17-2024
' 04-03-2024 08:48:08
' 04-03-2024 08:48:08
' 04-03-2024 08:48:08
' 04-03-2024 08:48:08
' 04-03-2024 08:48:08
' 04-03-2024 08:48:08
' SerSzuD2
' Windows (32-bit) NT :.00 XLToday 17.04.2024 VBAToday 17.04.2024
' 04.03.2024 08:48:08
' 04.03.2024 08:48:08
' 04.03.2024 08:48:08
' 04.03.2024 08:48:08
' 04.03.2024 08:48:08
' 04.03.2024 08:48:08
DocAElstein
04-18-2024, 02:35 AM
Later
DocAElstein
05-20-2024, 03:31 PM
later
.
.
.
..
.
.
.
SKKDJHskjasdhaskjdhaskdhjdhas
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
https://eileenslounge.com/viewtopic.php?p=317218#p317218 (https://eileenslounge.com/viewtopic.php?p=317218#p317218)
https://eileenslounge.com/viewtopic.php?p=316955#p316955 (https://eileenslounge.com/viewtopic.php?p=316955#p316955)
https://eileenslounge.com/viewtopic.php?p=316955#p316955 (https://eileenslounge.com/viewtopic.php?p=316955#p316955)
https://eileenslounge.com/viewtopic.php?p=316940#p316940 (https://eileenslounge.com/viewtopic.php?p=316940#p316940)
https://eileenslounge.com/viewtopic.php?p=316927#p316927 (https://eileenslounge.com/viewtopic.php?p=316927#p316927)
https://eileenslounge.com/viewtopic.php?p=317014#p317014 (https://eileenslounge.com/viewtopic.php?p=317014#p317014)
https://eileenslounge.com/viewtopic.php?p=317006#p317006 (https://eileenslounge.com/viewtopic.php?p=317006#p317006)
https://eileenslounge.com/viewtopic.php?p=316935#p316935 (https://eileenslounge.com/viewtopic.php?p=316935#p316935)
https://eileenslounge.com/viewtopic.php?p=316875#p316875 (https://eileenslounge.com/viewtopic.php?p=316875#p316875)
https://eileenslounge.com/viewtopic.php?p=316254#p316254 (https://eileenslounge.com/viewtopic.php?p=316254#p316254)
https://eileenslounge.com/viewtopic.php?p=316280#p316280 (https://eileenslounge.com/viewtopic.php?p=316280#p316280)
https://eileenslounge.com/viewtopic.php?p=315915#p315915 (https://eileenslounge.com/viewtopic.php?p=315915#p315915)
https://eileenslounge.com/viewtopic.php?p=315512#p315512 (https://eileenslounge.com/viewtopic.php?p=315512#p315512)
https://eileenslounge.com/viewtopic.php?p=315744#p315744 (https://eileenslounge.com/viewtopic.php?p=315744#p315744)
https://www.eileenslounge.com/viewtopic.php?p=315512#p315512 (https://www.eileenslounge.com/viewtopic.php?p=315512#p315512)
https://eileenslounge.com/viewtopic.php?p=315680#p315680 (https://eileenslounge.com/viewtopic.php?p=315680#p315680)
https://eileenslounge.com/viewtopic.php?p=315743#p315743 (https://eileenslounge.com/viewtopic.php?p=315743#p315743)
https://www.eileenslounge.com/viewtopic.php?p=315326#p315326 (https://www.eileenslounge.com/viewtopic.php?p=315326#p315326)
https://www.eileenslounge.com/viewtopic.php?f=30&t=40752 (https://www.eileenslounge.com/viewtopic.php?f=30&t=40752)
https://eileenslounge.com/viewtopic.php?p=314950#p314950 (https://eileenslounge.com/viewtopic.php?p=314950#p314950)
https://www.eileenslounge.com/viewtopic.php?p=314940#p314940 (https://www.eileenslounge.com/viewtopic.php?p=314940#p314940)
https://www.eileenslounge.com/viewtopic.php?p=314926#p314926 (https://www.eileenslounge.com/viewtopic.php?p=314926#p314926)
https://www.eileenslounge.com/viewtopic.php?p=314920#p314920 (https://www.eileenslounge.com/viewtopic.php?p=314920#p314920)
https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=314837#p314837 (https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=314837#p314837)
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.