Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have tried to make multiple selections in an excel sheet where there are formulas in each cell that is highlighted as shown below. I have tried copy/paste these cells, so they only show hardcoded values instead of formulas. Unfortunately, Excel doesn't allow this type of action when you have multiple selections. Is there a way to have multiple selections (as shown below) in Excel and copy only the selected cells and then paste the values with only having to use the paste special option once?

enter image description here enter image description here

question from:https://stackoverflow.com/questions/66050786/copy-paste-values-in-excel-multiple-selections

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
302 views
Welcome To Ask or Share your Answers For Others

1 Answer

I don't think there is any other way than using VBA in this case.

This code worked for me:

Sub myPasteSpecial()
  Dim cell As Range
  
  For Each cell In Selection
    cell.Value = cell.Value
  Next cell
  
End Sub

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...