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
 

cenky

New Member
Joined
Jul 30, 2014
Messages
10
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!
 

Some videos you may like

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Watch MrExcel Video

Forum statistics

Threads
1,127,098
Messages
5,622,682
Members
415,920
Latest member
ExcelNoob28

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
Top