Following number

%3CLINGO-SUB%20id%3D%22lingo-sub-3022213%22%20slang%3D%22en-US%22%3EFollowing%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3022213%22%20slang%3D%22en-US%22%3E%3CP%3EDear%20all%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20want%20a%20following%20number%20in%20a%20excel%20cell%20when%20re-opening%20the%20file.%20This%20worked%20with%20VBA%20code%20as%20shown%20below%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22%22%3EPrivate%20Sub%20Workbook_Open()%3C%2FDIV%3E%3CDIV%20class%3D%22%22%3ERange(%22D2%22).Value%20%3D%20Range(%22D2%22).Value%20%2B%201%3C%2FDIV%3E%3CDIV%20class%3D%22%22%3EEnd%20Sub%3C%2FDIV%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22%22%3E%3CFONT%20color%3D%22%23000000%22%3EBut%20now%20I%20want%20a%20text%20in%20front%20so%20%22IO-E-%20%26amp%3B%20Number.%20I%20don't%20get%20this%20done.%20Has%20anyone%20a%20solution%3F%3C%2FFONT%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3022213%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3022282%22%20slang%3D%22en-US%22%3ERe%3A%20Following%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3022282%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1230276%22%20target%3D%22_blank%22%3E%40Edwin1974%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESet%20the%20number%20format%20of%20cell%20D2%20to%20the%20custom%20format%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%22IO-E-%220%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20have%20to%20do%20this%20only%20once.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3022332%22%20slang%3D%22en-US%22%3ERe%3A%20Following%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3022332%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3Bdank%20je%20voor%20je%20reactie%20maar%20het%20is%20met%20niet%20duidelijk.%20Bedoel%20op%20deze%20manier%3F%20Dan%20krijg%20ik%20een%20fout.%20Ook%20met%20%26amp%3B%20ertussen..%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPrivate%20Sub%20Workbook_Open()%3CBR%20%2F%3ERange%22IO-E-%22(%22H3%22).Value%20%3D%20Range%22IO-E-%22(%22H3%22).Value%20%2B%201%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Dear all,

 

I want a following number in a excel cell when re-opening the file. This worked with VBA code as shown below:

 

Private Sub Workbook_Open()
Range("D2").Value = Range("D2").Value + 1
End Sub
 
But now I want a text in front so "IO-E- & Number. I don't get this done. Has anyone a solution?
3 Replies

@Edwin1974 

Set the number format of cell D2 to the custom format

 

"IO-E-"0

 

You have to do this only once.

@Hans Vogelaar dank je voor je reactie maar het is met niet duidelijk. Bedoel op deze manier? Dan krijg ik een fout. Ook met & ertussen..

 

Private Sub Workbook_Open()
Range"IO-E-"("H3").Value = Range"IO-E-"("H3").Value + 1
End Sub

@Edwin1974 

Nee, mijn suggestie heeft niets met VBA te maken. Laat de code zoals die oorspronkelijk was.

 

Selecteer de cel in het werkblad.

Druk op Ctrl+1 om het dialoogvenster Cellen Opmaken te tonen.

Activeer het tabblad Getal van het dialoogvenster.

Selecteer Aangepast in de lijst Categorie.

Voer in het tekstvak Type in:

 

"IO-E-"0

 

Klik OK.

De waarde van de cel blijft een getal, zoals je kan zien in de formule-balk, maar de weergave in de cel is zoals je verzocht. Zie het schermbeeld hier onder (uit de Engelstalige versie van Excel).

S0952.png