Hi all My problem is to create a macro allowing as soon as the file is opened (on a network & for several users), to put the date of today on the desired line as well as the color of the user who has written on a line the codification of the plan.
This allows you to track how much and by whom the plans are created.
Since the computer has a specific name in the network, users who code their plans in the table will be able to have a color code of their own. Is it possible?
If I understand correctly what you want to do: the user opens the excel file, indicates the plan number, closes the excel file?
Why not enter the date and username at the same time? I really like macros... but I'm a little afraid that you're complicating your file unnecessarily, right?
Derline = Sheet1.Cells(1, "B"). End(xlDown). Row' Will fetch the last non-empty row of the column cell "Date" sheet1 from cell "B3"
Sheet1.Cells(Derligne, "B") = Date 'Entered the date of the day's
coul = Cells.Find(Name, Cells(1, "E")). Interior.ColorIndex 'Retrieves the color of the box with the user name range(cells(derligne, "a"), cells(derligne, "c")). Interior.ColorIndex = color
End Sub
On the other hand, be careful. The username must be RIGOROUSLY the same between the excel file and the PC, otherwise it cannot find (the same spaces, the same capitalization, etc etc).
I continue to believe that it's a source of boredom for your thing!
Thank you coin37coin, No, don't tkt, it's for simplified a word file to fill in by hand. There are some who manage to make mistakes sometimes. when do we go too fast... Thank you I test all this.
Edit: As much for me, she wrote instead of the last line (little mismatch)
Sub AutoName()
Name = Application.UserName ' user name Derline = Sheet1.Cells(1, "B"). End(xlDown). Row' Will fetch the last non-empty row of the column cell "Date" sheet1 from cell "B3" Line = Derline + 1 'Add a line to go on a blank Sheet1.Cells(Line, "B") = Date
coul = Cells.Find(Name, Cells(1, "E")). Interior.ColorIndex 'Retrieves the color of the box with the user name range(cells(line, "a"), cells(line, "c")). Interior.ColorIndex = color
Here is the corrected macro but it will depend on the order of the user's actions:
He will first write in his reference at the end of the list ?
Sub AutoName()
Name = Application.UserName ' user name
Derligne = Sheets("Sheet1"). Cells(1, "A"). End(xlDown). Row' Will fetch the last non-empty row of the column cell "Date" sheet1 from cell "B3"
Sheets("Sheet1"). Cells(Derligne, 2). Value = Date 'Entered the date of the day
Set cell = Cells.Find(what:=Name, LookAt:=xlWhole) 'Retrieves the color of the box with the user name coul = cell. Interior.ColorIndex range(cells(derligne, "a"), cells(derligne, "c")). Interior.ColorIndex = color
For the button, you have to go to the "developer" tab => insert => Button
Then, you insert the button into your sheet as if it were a note (a left and right click to left to set the size) then a right click on the = button> assign a macro => select your macro from the list
On the other hand, of course, the macro must be in your visual basic before
To display the developer tab (if you don't have it), you have to go to file => options => Customize the ribbon => click the "developer" box in "main tabs" if you don't do so
I don't tell you in the file, because I think it's better to struggle a little and learn than to have a turnkey solution;)
Edit: you'll be careful, you leave a lot of information in your files between this question and the previous one. There is the name of your colleagues or the complete list of parts of your company. I advise you to edit your messages and to remove/modify them.
-> You write on the last line (ref 20244). And not on the last + 1 line Small line of modification to make as for my 2nd macro
-> You have reached the limits of the VBA: if it doesn't work, it's because you haven't written the user's name EXACTLY as it is entered in the machine. That's what I said at the very beginning of the question: it's going to be a perpetual source of error as soon as a new user bursts in.
I will therefore advise you to do a small macro to do with each user based on:
Sub DefName ()
Name = Application.UserName
ActiveCell = Name
End Sub
You just have to select the box where to put the name, launch the macro and presto, it's filled in correctly. To do for each of the people present