Iran war turns hot again: US releases moment it boarded tanker, Iran 'attacks American ships with drones' and oil prices surge - Live updates
I'm A Celeb South Africa hosts Ant and Dec blast David Haye in rare comments - after Adam Thomas said the boxer 'broke him' during his time on show
Reform says it will deport up to 400,000 asylum seekers if it wins the next election, creating 'pop up' detention centres to hold thousands
CHRISTOPHER STEVENS reviews Queen Elizabeth II: Her Story, Our Century: Captured in an unseen ten-second clip, Queen Elizabeth's very essence
Zoom Partners With Sam Altman's Iris-Scanning Company To Offer Callers Verifications of Humanness
Read more of this story at Slashdot.
Next.js developer Vercel warns of customer credential compromise
Vercel, the company that created the open source Next.js web development framework, has a data leak that led to compromise of some customer credentials, and blamed an outfit called Context.ai for the mess.…
Inside Graham Norton's 'ruthless' new ITV show The Neighbourhood where families on a real street compete in backstabbing challenges for a £250,000 prize - and it makes The Traitors look tame
Greece ditches fingerprint and facial scans for Britons after new EU travel rules sparked border chaos across Europe
Traffic light failure causing delays on route in and out of Essex near major airport
Yew cannot be serious! Cockerel hedge that was village landmark for 110 years is chopped down and replaced with gargoyle
Horror as man dies after 300kg of glass falls onto him in Dural
Horrific scenes in Mayfair as female driver ploughs her car into 'influencer' and other pedestrians near nightclub at 4.30am as shocked crowd looks on
Former Army National Guardsman who killed EIGHT kids in horror Louisiana rampage was father to some of the victims
'Invisible mouse' made a mess of PC rebuild
Who, Me? Welcome to yet another Monday, and therefore to this week's edition of Who, Me? For those unfamiliar, it's The Register's reader-contributed column that shares your stories of workplace messes, and how you tried to clean them up without dirtying your career prospects.…
Meet Mr Rosamund Pike: The VERY upper class, twice-divorced eccentric ex-heroin addict 20 years her senior who almost nobody knew existed until she name-checked him at the Oliviers
Meet Mr Rosamund Pike: The VERY upper class, twice-divorced eccentric ex-heroin addict 20 years her senior who almost nobody knew existed until she name-checked him at the Oliviers
CodeSOD: Good Etiquette
"Here, you're a programmer, take this over. It's business critical."
That's what Felicity's boss told her when he pointed her to a network drive containing an Excel spreadsheet. The Excel spreadsheet contained a pile of macros. The person who wrote it had left, and nobody knew how to make it work, but the macros in question were absolutely business vital.
Also, it's in French.
We'll take this one in chunks. The indentation is as in the original.
Public Sub ExporToutVersBaseDonnées(ClasseurEnCours As Workbook) Call AffectionVariables(ToutesLesCellulesNommées) Call AffectationBaseDonnées(BaseDonnées) BaseDonnées.ActivateThe procedures AffectionVariables and AffectationBaseDonnées populate a pile of global variables. "base de données" is French for database, but don't let the name fool you- anything referencing "base de données" is referencing another Excel file located on a shared server. There are, in total, four Excel files that must live on a shared server, and two more which must be in a hard-coded path on the user's computer.
Oh, and the shared server is referenced not by a hostname, but by IP address- which is why the macros were breaking on everyone's computer; the IP address changed.
Let's continue.
'Vérifier si la ligne existe déjà. If ClasseurEnCours.Sheets("DATA").Range("Num_Fichier") = 0 Then Num_Fichier = BaseDonnées.Sheets(1).Range("Dernier_Fichier").Value + 1 Insérer_Ligne: '(étiquette Goto) insérer une ligne Application.GoTo Reference:="Dernière_Ligne" Selection.EntireRow.Insert 'Copie les cellules (colonne A à colonne FI) de la ligne au-dessus de la ligne insérée. With ActiveCell .Offset(-1, 0).Range("A1:FM1").Copy 'Colle le format de la cellule précédemment copiée à la cellule active puis libère les données du presse papier .PasteSpecial .Range("A1:FM1").Value = "" 'Se repositionne au début de la ligne insérée. .Range("A1").Select End With Application.CutCopyMode = FalseUh oh, Insérer_Ligne is a label for a Goto target. Not to be confused by the Application.GoTo call on the next line- that just selects a range in the spreadsheet.
After that little landmine, we copy/paste some data around in the sheet.
That's the If side of the conditional, let's look at the else clause:
Else Cherche_Numéro_Fichier: ' Chercher la ligne ou le numéro de fichier est égale à NumFichier. While ActiveCell.Value <> Num_Fichier If ActiveCell.Row = Range("Etiquettes").Row Then GoTo Insérer_Ligne End If ActiveCell.Offset(-1, 0).Range("a1:a1").Select Wend 'Vérifier le numéro d'indice de la ligne active. If Cells(ActiveCell.Row, 165).Value <> ClasseurEnCours.Sheets("DATA").Range("Dernier_Indice") Then ActiveCell.Offset(-1, 0).Range("A1:A1").Select GoTo Cherche_Numéro_Fichier End If ActiveCell.Offset(0, 0).Range("A1:FM1").Value = "" End IfWe start with another label, and… then we have a Goto. A Goto which jumps us back into the If side of the conditional. A Goto inside of a while loop, a while loop that's marching around the spreadsheet to search for certain values in the cell.
After the loop, we have another Goto which will possibly jump us up to the start of the else block.
The procedure ends with some cleanup:
'----- ' Do some stuff on the active cell and the following cells on the column .----- BaseDonnées.Close True Set BaseDonnées = Nothing End SubI do not know what this function does, and the fact that the code is largely in a language I don't speak isn't the obstacle. I have no idea what the loops and the gotos are trying to do. I'm not even a "never use Goto ever ever ever" person; in a language like VBA, it's sometimes the best way to handle errors. But this bizarre time-traveling flow control boggles me.
"Etiquettes" is French for "labels", and it may be bad etiquette but I've got some four letter labels for this code.