Forum Discussion
How to not overwrite cells in filtered table using copy and paste values
Hi,
I have search for an answer to this question without satisfactory results. I hope someone here at the forum can help me out.
The problem is that sometimes when I copy and past a value from one cell into many cells in a filtered table, the value also gets copied into invisible cells. I have found that it may have to do with the selected pasting option. Because it seems as if the problem only occurs (but I am not sure) if I copy and paste “values” (or formulas, or any other pasting option other than the default paste option). Is there any way to make sure that Excel only copies and past even formulas or values into visible cells?
Example.
Pic 1 - In the table below I will filter column A and only see the rows with “Jan”.
Pic 2 - I then write “ok” in the first cell and copy and paste (using keyboard shortcuts, ctrl c, ctrl + spacebar and then ctrl v) that into all the rows matching the value “Jan”.
Pic 3 – The result is fine.
Pic 4 – I did the same thing but copy and pasted “values” into all visible cells instead of using keyboard shortcuts. The result is as you can see that all cells got the “ok”.
Thanks in advance for any help given.
Brgs,
Victor
15 Replies
- SRS_SebastianCopper Contributor
Hi, just yesterday ran into the same problem.
The problem with pasting multiple selection of cells over a filtered area overwriting hidden cells was well known to me. However, never expected the same issue to exist with one cell selection over a filtered area in combination with the new paste values only (ctrl+shift+v) or the paste special (ctrl+alt+v) / (ctrl)+function after pasting. Just pasting with no "special" selection works fine, pasting values only or formulas not...
Little rant: Would be great if microsoft could fix these issues. Especially for business users working on critical data in excel this is detremental.All search seems there is no proper fix for this. Your friend will be "Select Visible Cells" function. Shortcut (alt+;) was strangely however not working for me. If you have the same issue: home > find & select > go to special / (ctrl+g) or (F5) / or put it to your quick access toolbar.
In case you need a shortcut fix in the meantime, until hopefully microsoft finally fixes this, AutoHotkey is your friend, my solution for paste values and paste special:
#Requires AutoHotkey v2.0
; Only active when Excel is the foreground window
#HotIf WinActive("ahk_exe EXCEL.EXE")^+x:: { ; Ctrl + Shift + X
try {
xl := ComObjActive("Excel.Application") ; Get running Excel instance
selCount := xl.Selection.Cells.Count ; Count selected cells
} catch {
return ; if Excel isn't available, do nothing
}if (selCount > 1) {
; Step 1: Select Visible Cells Only (Home > Find > GoToSpecial)
Send("!hfdsy") ; Alt + H F D S Y
Sleep 50
Send("{Enter}")
Sleep 50
}; Step 2: Paste Values (Ctrl + Shift + V)
Send("^+v")
return
}
#HotIf---AND---
#Requires AutoHotkey v2.0
; Only active when Excel is the foreground window
#HotIf WinActive("ahk_exe EXCEL.EXE")^+d:: { ; Ctrl + Shift + D
try {
xl := ComObjActive("Excel.Application") ; Get running Excel instance
selCount := xl.Selection.Cells.Count ; Count selected cells
} catch {
return ; if Excel isn't available, do nothing
}if (selCount > 1) {
; Step 1: Select Visible Cells Only (Home > Find > GoToSpecial)
Send("!hfdsy") ; Alt + H F D S Y
Sleep 50
Send("{Enter}")
Sleep 50
}; Step 2: Paste Special (Ctrl + Alt + V)
Send("^!v") ; Ctrl + Alt + V
return
}
#HotIf---QuickAccess---
if you put the function on your quick access toolbar, Step 1 can be shortened:
; Step 1: Select Visible Cells Only (Alt + 3 on QAT)
Send("!3") ; Alt + 3
Sleep 50 ; small pause- Victor107200Brass Contributor
Thanks for the detailed reply and possible solution. The issue seems to be irregular and was encountered some time ago, as indicated in the initial question. So maybe it is fixed or maybe I have not been paying attention and already overwritten cells with the wrong values by mistake.
- SRS_SebastianCopper Contributor
Welcome
Since I came through here when I encountered the problem, and you made a very good description of the problem, thought I put my solution for others experiencing the same.
And hopefully someone with Microsoft will see and it's getting finally fixed. As I just now encountered it, definitely is still overwriting cells unintentionally.
- Victor107200Brass Contributor
Thanks for the detailed reply and possible solution. The issue seems to be irregular and was encountered some time ago, as indicated in the initial question. So maybe it is fixed or maybe I have not been paying attention and overwritten cells with the wrong values by mistake. How knows...
- SRS_SebastianCopper Contributor
FYI - Put a shortcut to your .ahk file to %AppData%\Microsoft\Windows\Start Menu\Programs\Startup to run automatically.
- Wouter_ACopper Contributor
Victor107200
I am familiar with this bug. I am a consultant and both me and my clients frequently work in excel.
On my end it seems to happen in regular (non table) cells as well when many users filter rows and use the "only show my own filters" option.- TunisiaMCopper Contributor
I'm wondering why I keep overwriting data in our shared file where everyone uses "only show my own". Thank you for the information.
- travis1275Copper ContributorHow do we fix it? It has bothered me for years now. I no longer trust excel because of it.
- dscheikeyBronze Contributor
Victor107200Hello Victor, I have tried to reproduce your scenario. In both cases, only the visible cells were described with oK. I have tested under Excel for the Web. Which operating system and which Excel version are you working with? That would certainly be interesting for other testers.
- travis1275Copper Contributor
dscheikey This is very true. If you have a ton of lines, Excel will overwrite invisible cells on a CTRl + P. It happens to me all the time. It never did it in the past, but in the last few years, it has happened daily. I have no idea why, either! I no longer trust excel... Large files, Excel is crap anymore.
- Victor107200Brass ContributorHello, Thanks for your reply.
MicrosoftS Excel Microsoft 365 MSO (Version 2209 Build 16.0.15629.20200) 64-bit
Windows 10 Pro, Version 21H2, OS-version 19044.2130
I also reproduced it now in Excel for the web and was suprised to see that as you say, only the visable cells gets "ok" copied to them. Very strange.- SnowMan55Bronze Contributor
You may wish to review how this has been discussed elsewhere , and if you page + scroll to the responses by member Cangkir, how to resolve it with a procedure/macro.