Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 389
  • Last Modified:

How to insert two pieces of Visual Basic code into the same workbook / worksheet

Hi Guys

I know Im really slow when it comes to things like this as im not a programmer - I just ask you guys for help

I have a spreadsheet and I want to insert two pieces of code (from here actually) - one that auto colours cells when a certain letter is inserted - this is in and working great, but I have another that I need to insert into the same sheet that performs another function.

Can you help

Much appreciated

Jase
0
Jase Alexander
Asked:
Jase Alexander
  • 2
  • 2
1 Solution
 
zorvek (Kevin Jones)ConsultantCommented:
Just copy and paste the two chunks of code into the same module - one after the other. They can both co-exist in the same module at the same time as long as they don't share the same routine name.

Kevin
0
 
Jase AlexanderCompliance ManagerAuthor Commented:
Thanks for the reply

I have two routines which both start with Private Sub Worksheet_Change but when I try and enter them in the same module, it gives me an Ambiguous Name Error or something - is there a way around this?

Cheers
Jase
0
 
zorvek (Kevin Jones)ConsultantCommented:
Yes, place the code within the second routine into the first routine:

Private Sub Worksheet_Change(ByVal Target As Range)

' Code from first routine.

' Code from second routine.

End Sub

Kevin
0
 
Jase AlexanderCompliance ManagerAuthor Commented:
Fab !!

Thanks for the quick response
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now