Solved

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

Posted on 2013-05-21
4
383 Views
Last Modified: 2013-05-21
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
Comment
Question by:Jase Alexander
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 39183950
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
 

Author Comment

by:Jase Alexander
ID: 39183968
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
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 500 total points
ID: 39183970
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
 

Author Closing Comment

by:Jase Alexander
ID: 39184037
Fab !!

Thanks for the quick response
0

Featured Post

Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question