VBA doesn't allow copy/paste

Salad Fingers

New Member
Joined
Dec 8, 2021
Messages
11
Office Version
  1. 2016
Platform
  1. Windows
I have a workbook with several sheets. Only in one of them I have a VBA code::
Private Sub Worksheet_SelectionChange (ByVal Target As Range)
Application.Calculate
End Sub

The VBA code doesn't allow me to copy/paste from one cell to another in this particular sheet.
Could you help me with a solution to have the ability to copy/paste without removing the VBA?
If you need more information, I would gladly provide it.
Thanks
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Welcome to the Board!

That code will essentially abandon/kill any copy/paste in progress as you move from one cell to another.
What is the purpose of this code?
I am thinking that there is a probably a better way to do with whatever it is you are trying to accomplish with that bit of code.
 
Upvote 0
I am using it in order to have multiple searchable drop down lists in the same sheet. Otherwise they won't work. There might be a better way, but I am a beginner so I am not too sure how to go about it.

I watched this video and replicated the method shown in it:
 
Upvote 0
If you need it to recalculate when some value is selected, you can limit it to run JUST on the update of specific cells (using Target).
That way it doesn't disable that for all cells.
 
Upvote 0
"Target" isn't a function, it is the parameter used in this VBA code.
In event procedure VBA code like this, "Target" is the range that triggered this code to run (it is right in the first line, i.e.):
Rich (BB code):
Private Sub Worksheet_SelectionChange (ByVal Target As Range)

So, what you can do is check to see in the "Target" range (the range that triggered this code to run) is the range you want the update to run on.
Quite frankly, I think it is better to use the "Worksheet_Change" event procedure, which only runs when data is changed, as opposed to "Worksheet_SelectionChange", which runs whenever a cell is selected.

For example, if your drop-down boxes were in cells A1, A10, and A25, you could write your code like this:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Or Target.Address = "$A$10" Or Target.Address = "$A$25" Then
        Application.Calculate
    End If
End Sub
I think that should do what you want. You just need to identify all the cell addresses with your interactive drop-down boxes.
 
Upvote 0
I tried this way, however once I copy and paste a cell my dropdown menus stop working. Also i need to be able to copy and paste other cells without the dropdown list
 
Upvote 0
Which cells contain your drop-downs?
Which cell are you trying to copy specifically that is causing you issues?
What is the purpose of copy/pasting that cell?
 
Last edited:
Upvote 0
My table is A:S with 35 rows. My searchable drop down lists are contained in column F (every row of the column contains a searchable drop down list)
I am trying to have a table where every cell could be copy / pasted (doesn't matter if it is a cell containing the searchable list or a "normal" cell with text in it.
The purpose of copy/pasting around is to save time filling the table.
My problem is that when I copy a cell, my searchable drop downs stop working (when I click the drop down list doesn't show)
 
Upvote 0
@Salad Fingers
See if this helps:
I created an add-in called “Search deList”, and I shared it as a freeware, and also the code is not protected so you can check it & amend it as needed.
Its function is to speed up searching in data validation list. In any cell that has data validation (with List type) pressing ALT+RIGHT will open a Userform with a combobox. You can type multiple keywords (separated by a space) in the combobox and the list will be narrowed down as you type.
You can use up-down arrow to select an item, then hit ENTER, the selected item will be inserted into the cell, and the Userform will be closed.
And also you don't need vba.
I posted the add-in in this thread: LINK

OR

If you don't want to install the add-in, there's another option, which is using vba. See in this thread: LINK
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,649
Members
448,975
Latest member
sweeberry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top