Issue with Copying Excel Cells - excel

I am not sure if there is a solution to this issue. In Excel when you copy a cell the border starts moving/flashing. Only when that border is moving you are allowed to paste its contents into another cell. Once the border is no longer moving, you are also unable to paste its contents. The other option is to double click on the cell or go into the formula bar to manually copy the data, which then you can paste as much as you want, at least until something else is copied.
Here is my problem. I have script within the “Private Sub Worksheet_SelectionChange(ByVal Target As Range)” section of my worksheet. So every time another cell is selected this script is run. The script works perfectly and I do not need this changed. The spreadsheet first needs to be unlocked before the script can run, so I had to put this at the top of the script “ActiveSheet.Unprotect” and this at the bottom “ActiveSheet.Protect”. When I select a different cell and the code hits either the unprotect or the protect commands, then the copied cell border is no longer flashing, so I can’t paste.
Is there a script of some sort that I can use so it retains the copied data? The script should only run when a cell is copied. I also don’t want to use the SendKeys function because that typically causes more issues then what it solves. I have always been wondering where Excel stores its data for copied cells, since usually copied data is stored in the windows clipboard, or some other dumping ground since Windows 7 & 8 no longer use the clipboard for copping data. So I don’t understand why Excel doesn’t use the same method as everything else when a cell is copied.
This isn’t too much of an issue, more of an annoyance than anything. If someone should have a solution to this please let me know, but I don’t think there is one.

Related

Vba excel: invisibility if data in cells

I am dumping data from one sheet to another using vba code .All cells are getting correctly populated except 6 cells in the beginning.Actually the data us populated in these cells but its not visible until I double click on the cells.What is going wrong.Can someone help?
If you are blaming the wrong format you have two options:
a) clear the format of the destination cells, e.g. Worksheets("DestinationSheet").Range("A1:A6").ClearFormats and then copy the data without formatting
b) copy the format from some cell whose format is correct, e.g. Worksheets("DestinationSheet").Range("B1").Copy Destination:=Worksheets("Sheet1").Range("A1:A6") and then copy the data without formatting (this means you copy good format but wrong data first, but then in the next action you are going to overwrite the wrong data with good data)
Note 1: to copy the data without formatting it is better to use direct assignment Worksheets("DestinationSheet").Range("A1:A61").Value = Worksheets("SourceSheet").Range("A1:A6").Value than Copy function
Note 2: In my view it is always better to avoid using Copy & Paste in two commands because you are messing with the system clipboard, which it dangerous at least. Just imagine the user wants to use the clipboard in another program at the same time you are running the macro in Excel... To my best knowledge, the Copy function above (without being followed by Paste) does not use the system clipboard (please someone do correct me if I am wrong)

Copy-Paste Excel 2010

After copying and pasting cell(s) (does not matter whether by keyboard shortcut or bar menu), pasting doesn't work properly. The result works like opposite of "copy down" function. If I am pasting into one row range, the value from row below is pasted. If I am pasting into more than one row range, the content of bottom row is copied to entire range.
It is happening only in one particular table (which is just too difficult to reconstruct).
I have no idea why this happened, seems I might have clicked some unfortunate keyboard shortcut, but I have no idea how to get it back. Reopening excel or deleting Personal.xlsb file didn't help.
Edit:
I tried to make the table as small as possible and realized that the copy-paste worked fine after deleting a certain number of columns. When I added new columns (to have the table like before), the copy-paste didn't work again.
Could it be a memory problem (the table is quite bulk)?

Auto populate column by reference?

I am working on the following sheet, called Raw_Data:
In a new sheet, I want to copy the registration_date column by reference. This means that if I change the registration_date on the Raw_Data, the changed value should be reflected in the new sheet.
To implement this, I have entered the following =Raw_Data!C2. So far it works fine as you can see below:
But the problem is that when I double click on the little green square here, it doesn't automatically populate the entire column.
I don't want to manually drag-and-drop because there are several thousand rows. Does anyone know how I could automatically populate the column by reference?
While there are some automation things you could do, I think a lot of that would be overkill for what could be just an input issue with how you are choosing to copy in Excel.
If you find that you need to copy a large block of data, rather than dragging the corner of your cell like that, try one of these alternate methods:
While selected on the cell, press CNTRL + C. Then in the 'Name Box' (where it shows the address of the cell you are on), type in the cell where you want to go (A17000); then press SHIFT + ENTER. This will jump you to that cell, and will highlight all cells inbetween where you were and where you are going. Then press CNTRL + V.
Another method of moving around a large data block in Excel is to hold CNTRL and press an arrow key. This will move you as far down the data block as possible. Note that this will not work on a blank sheet, as there is no data and therefore Excel doesn't know when to stop.
Again - some automation would be possible here, but moving around an Excel worksheet is something you will be doing too frequently in too many different ways to want to automate what might be 5 keystrokes once a week.
In excel the "double click to fill" feature is a heuristic based feature that fills the cells that appear to be relevant with the selected formula (+ reference corrections).
In your case there is no hint the heuristic can use to tell what to fill so nothing is being done.
Regarding dragging "several thousand rows", that's not a real problem. If you only do it once, there no reason to even trying anything "smart" or complicated.
You can also copy the source cell, select all the cells you want to fill and then paste. You can select cells in any way you like, not just dragging.
You could instead of all the dragging/copying/filling approach simply copy directly from the source, and paste by reference.
As a last resort, you can always go for a VBA solution to do that for you.

Change default paste options

Since a few hours ago, when I paste with Ctrl+V in Excel 2010, it pastes values, not formulas. It appears that the default has changed, I do not know how.
From what I found, that can only be done assigning the shortcut to a suitable macro (I know I did not do that!).
Any hint on how to change it?
I was copying a range which span hidden cells due to filtering. Then, pasting used "as values" by default. When the copied range did not span any filtered out cell, paste went back to normal.
Something new/unexpected every day (especially when it comes to MS)...

Groovy POI created cells considered blank by other programs until ENTER is manually pressed in cells

Ok this is kind of hard to explain.
I create a cell in my worksheet using JAVA POI
newCell= row.getCell(index)
if (containerCell == null) {
containerCell = row.createCell(index)
}
newCell.setCellType(HSSFCell.CELL_TYPE_STRING)
newCell.setCellValue(strVar)
If i then open the worksheet in EXCEL, I see that the cell value is indeed set. However if I load this into another external program that reads EXCEL sheets, it claims the cell I just set is blank.
NOW, if I go back into excel and do a simple "Hit return" on the cell in question, in the formula bar (even though its not a formula) and try to reload it into the external program, it works fine. Do I need to evaluate a formula on a string?
Thanks
I have no experience with Java, but having to hit enter in a cell is usually indicative of calculation being set to manual. Since you are working with API it may be treating your input from Java as a formula (?).
Open the offending workbook in its broken state, and on the sheet you are having problems with choose [Formulas] tab at top, then [Calculation]>Calculate Sheet.
If this updates the value then I see two options...
See if there is an option to manually calculate the sheet with POI, after the value has been entered.
Alternatively, you can write just a tiny bit of VBA to force calculation on that sheet when workbook is opened. MSDN offers a simple example.
http://msdn.microsoft.com/en-us/library/office/aa223802%28v=office.11%29.aspx
I have had to do this for Excel apps where calculation had to be set to manual to avoid excessive overhead. Just a guess though..
I am not sure why this was happening.. and evaluating the individual cells did not solve it however running evaluteAll() on the entire workbook made it work!

Resources