More Private Sub dont work together

cenky

New Member
Joined
Jul 30, 2014
Messages
10
Hello I have two Private Sub codes (one for ComboBox and one for rightclick) working properly sepatately. But when they are together, excel publish Run Time error 1004 (it cant copy simple cell and paste it). Will somebody help me?
Here is the code:

Private Sub ComboBox1_Change()

Select Case Range("D45").Value
Case "1dosp"
Úvěr_1
Case "2dosp"
Úvěr_2

Case Else
Exit Sub

End Select

End Sub
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
RightClick4
Cancel = True
End Sub
 
Does this work for you?

Code:
Sub Úver_2()
    With Sheets("Úvery_2")
        .Range("D43").Copy .Range("D46")
    End With
    Application.CutCopyMode = False
End Sub

Now it works! I asked a friend and he made a little change in the code:
"Sub Úvěr_1()
Sheets("Úvěry").Activate
Application.CutCopyMode = True
Range("D46").Value = Range("D42").Value
Range("D6").Select
Application.CutCopyMode = False
End Sub
Sub Úvěr_2()
Sheets("Úvěry_2").Activate
Application.CutCopyMode = True
Range("D46").Value = Range("D43").Value
Range("D6").Select
Application.CutCopyMode = False"

Anyway, thanks for the effort!
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,214,813
Messages
6,121,706
Members
449,048
Latest member
81jamesacct

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