I have a range of readonly cells.After that all other cells are editable.I want to know how can I detect this cell editing event.Like if cell A25 is edited,I want to call a procedure.
If Cell(A25).edited then do this.Some thing like this
You need to use the Worksheet_SelectionChange event as highlighted in my answer to one of your other questions.
May I suggest that now would be a good time to go and learn a bit more about Excel events and what you can and can't do with them, rather than asking multiple similar questions?
The following links may help:
http://www.cpearson.com/excel/events.htm
http://www.mvps.org/dmcritchie/excel/event.htm
http://www.ozgrid.com/VBA/ExcelWorkbookEvents.htm
Though i'm not sure if you can trigger this modification event somehow with VBA, I think there's better way to handle your read-only cells. Set them as protectable in cell format window, and then protect your sheet. After that everybody would be able to edit all the cells except the ones you marked as protectable.
Related
Excel
The input cells are marked with colour upon inserting a formula. But upon selecting formulas, the cells are not dispayed/marked, and this makes the spreadsheet less readable and thereby reduce my workflow.
The problem has been presented here too, but without any proper answer/solution:
https://superuser.com/questions/1228416/cells-referenced-in-formula-not-displaying
Inserting a formula
Selecting a cell with a formula
I did as explained by others in the link provided, but they didn't help unfortunately.
PS. I do have macros enabled, and work with them a bit. But nothing that should turn on/off such functions...
Unfortunately, I didn't manage to identify what caused the problem, and neither the solution.
I ran my macro a couple of times, and it suddenly worked. I don't even remember if it was at the first run.
Sorry guys, for you others might looking for the same solution as I did...
The macros were only making some formulas and autofill them for specific ranges...
I could not find an answer to this, neither on Stack or on the wild web. I have a sheet where I need users to be able to use Text to Columns, however, I also need to protect the sheet. Everything works fine if Excel automatically does this (from Text to Column "short-term memory"), but I cannot access the option when protection is enabled.
It is not that any text is spilling onto locked cells, it's just that the option is greyed out after protecting the sheet. I would appreciate a non-VBA answer as I do not want to use macros on a shared file (the server is extremely slow and even normal excels take ages to save). However, if absolutely necessary, can you ninjas please tell me how I can set it up so that this problem is solved with the least possible performance hit?
P.S.: I am pretty new to VBA (practically uninitiated, I prefer R for everything). Also, the shared server is basically a network folder, so it is not likely that it will cause any issues other than being super-sloth.
If you protect a sheet, then only unlocked cells can be edited, that is, users can change the cell manually.
That is the core and purpose of sheet protection.
In a protected sheet you will not be able to perform a text to columns manually.
Whether or not the file lives on a server is totally unrelated to using VBA for a solution.
The real question is: What are you trying to achieve? Your question is about running Text to Columns on a protected sheet, but if you step back from that particular approach, there may be other ways to achieve what you really need to do.
The point would be to automatically keep a "last" value (without, the human-error-prone: "just remember to do it" method), so that when changes are made the next time the spreadsheet is updated, they can be easily compared.
Update:
I'd still prefer to do this without macros, if possible.
But, since that's apparently not possible; what would the macro look like to do this?
How to place excel VBA code on save event
You can use an event trigger. I think you have to have a macro. You're basically asking this to be automatic - which means having to code something to do it for you. Using a spreadsheet formula would mean it will display current values... it wouldn't stick to the last value.
So here is what I want to do in VBA:
Find the value in E10, copy the row it is in, paste the row somewhere else (doesn't matter as long as I can find it) then finding the next row with the value E10 and doing the same thing, etc, until I reach the end of the spreadsheet
I'm really new to VBA and macros in general, so any help would be appreciated!
Generally speaking you'll find that asking questions without explaining "what have you tried" tends to be frowned upon in these parts.
I suggest that you take a look at this somewhat similar question that I answered just earlier today:
Copy & Paste row of data in Excel 2003 to different sheet by Email search
The principal differences between that one and your need are:
Instead of an InputBox, you'll use the value in E10 to run the .Find method; and
You need to create a loop. You still run the .Find method as shown in my example but you do it in a loop until you've looped through every instance of the value in E10 in the sheet. (Get the address of the first range that you find, and keep running the .Find method until you get back to that address.) Look up the While statement and the For statement in VBA help for examples on how to create a loop.
To get the value of an individual cell one way is just to create a reference to the cell range, then query the .Value property. For example a fully qualified reference could be:
Thisworkbook.Worksheets("Sheet1").Range("E10").value
There are other syntaxes which will yield the same result, but you can learn about those in time. Recording your actions using the Macro Recorder is a good way to learn about properties and methods. The problem is that in yet another part of the Excel 2010 interface that I detest, Microsoft has decided to hide the thing. To get to the Macro editor, go to File -> Options -> Customise Ribbon and turn on the Developer tab.
Give all of that a try and if you get stuck with something specific, post again with the details.
A tricky one, I assume. However, is there a way to make use of a selected or clicked cell in Excel somehow without the need for VBA?
(I know how to do it with VBA, but macros are macros, but if you want to give workbooks to people...)
For instance, I would like to make some of the content in the freezed section to be dependent on where in the sheet someone is. It would be optimal, if the selected cell/row would be trigger enough.
It would be also okay, if clicking a cell (e.g. a link navigating in the sheet) would trigger the conent to change. Hence, a solution would be to make a hyperlink change a value in some cell somewhere. I know, this is a different question, but it should be all accomplishing the same goal of the line on top ;-)
Thanks a lot!
You cannot change values or display of another cell with formula or functions.
The hyperlink will send you to another location but won't change the freezed part, except if you only freeze rows and the hyperlink send you to a further column. But you will have then to really think about your layout very precisely. Moreover, the user will even less understand what happens unless you can design a great UI (but Excel may not be the best tool though).
Some tips:
Use hyperlinks but on differents sheets
Use "transparent" macros (without big buttons but rather event vba as you pointed out)
Sorry i don't have a magical solution.