?
Solved

Combine two macros as one

Posted on 2016-08-18
7
Medium Priority
?
58 Views
Last Modified: 2016-08-18
Hi Experts Using Excel 2013

How would i combine the two together so macro one runs then two runs...

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Me.Range("$B$3")) Is Nothing Then LoadData
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Address = "$B$3" Then
        Call CopyandPasteValues
    End If
End Sub

Open in new window

0
Comment
Question by:route217
7 Comments
 
LVL 18

Assisted Solution

by:xtermie
xtermie earned 500 total points
ID: 41760791
Hi, something like this?
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("$B$3")) Is Nothing Then LoadData
If Target.Address = "$B$3" Then Call CopyandPasteValues
End Sub

Open in new window

0
 
LVL 33

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 1000 total points
ID: 41760821
Why not only this.....

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Target.Address = "$B$3" Then
   Call LoadData
   Call CopyandPasteValues
End If
End Sub

Open in new window

0
 
LVL 27

Assisted Solution

by:ProfessorJimJam
ProfessorJimJam earned 500 total points
ID: 41760822
you can remove unnessesary trigger of B3 which both line are doing the same thing. so here it goes simplified.

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Me.Range("$B$3")) Is Nothing Then LoadData
    Call CopyandPasteValues
End Sub

Open in new window

1
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 33

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41760824
Good to see you Professor after a long time. :)
1
 
LVL 27

Expert Comment

by:ProfessorJimJam
ID: 41760826
Thanks Neeraj,

likewise. good to see you too.

yes, it been a long time :-) i have been away summer holidays.
0
 

Author Comment

by:route217
ID: 41760836
Thanks all excelled as always..and excellent feedback..see the error.
1
 
LVL 33

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41760984
You're welcome. Glad to help.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

850 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