Solved

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

Posted on 2013-05-21
4
336 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:spicecave
  • 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:spicecave
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:spicecave
ID: 39184037
Fab !!

Thanks for the quick response
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now