obiwann

Board Regular
Joined
Jan 2, 2014
Messages
109
I have two cells, O14 and U14 that contain variables. The code works when Cell O14=5 and U14 =1 and the code works if O14=3 but when O14=5 and U14 = anything else the last set of code for ELSE: does not run. What am I doing wrong?

Code:
Sub Dump_Data()
 
 If Range("o14").value = 5 And Range("u14") = 1 Then
        Range("dq30").Copy
        Range("f18").Select
        ActiveSheet.Paste Link:=True
        Range("ds30").Copy
        Range("f19").Select
        ActiveSheet.Paste Link:=True
        Range("du5").Copy
        Range("ak19").PasteSpecial
        Range("du6").Copy
        Range("ao19").PasteSpecial
        Range("du7").Copy
        Range("as19").PasteSpecial
        Range("du8").Copy
        Range("aw19").PasteSpecial
        Range("du9").Copy
        Range("ba19").PasteSpecial
        Range("du10").Copy
        Range("be19").PasteSpecial
        Range("dy30").Copy
        Range("a14").PasteSpecial
   
 ElseIf Range("o14").value = 3 Then
        Range("dq30").Copy
        Range("f18").PasteSpecial
        Range("ds30").Copy
        Range("f19").PasteSpecial
        Range("dt30").Copy
        Range("ak19").Select
        ActiveSheet.Paste Link:=True
        Range("du30").Copy
        Range("ao19").Select
        ActiveSheet.Paste Link:=True
        Range("dv30").Copy
        Range("as19").Select
        ActiveSheet.Paste Link:=True
        Range("dy30").Copy
        Range("a14").PasteSpecial
        
 
Else: Range("dq30").Copy
        Range("f18").Select
        ActiveSheet.Paste Link:=True
        Range("ds30").Copy
        Range("f19").Select
        ActiveSheet.Paste Link:=True
        Range("du5").Copy
        Range("ak19").PasteSpecial
        Range("du6").Copy
        Range("ao19").PasteSpecial
        Range("du7").Copy
        Range("as19").PasteSpecial
        Range("du8").Copy
        Range("aw19").PasteSpecial
        Range("du9").Copy
        Range("ba19").PasteSpecial
        Range("du10").Copy
        Range("be19").PasteSpecial
        Range("dy30").Copy
        Range("a14").PasteSpecial
   End If
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

MUKESHY12390

Well-known Member
Joined
Sep 18, 2012
Messages
889
Office Version
  1. 2013
  2. 2011
  3. 2010
  4. 2007
Platform
  1. Windows
I would suggest debug code/run code by using F8 and try to see in that scenario which IF executes.

here about one thing I'm sure that one criteria will run whenever you run this code.
 

Forum statistics

Threads
1,136,331
Messages
5,675,156
Members
419,552
Latest member
jsanjur

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