Code to Disregard VBA or to Execute if Condition Met

VinceF

Board Regular
Joined
Sep 22, 2007
Messages
172
Office Version
  1. 2016
Platform
  1. Windows
Greetings,
Hopefully this is an easy one for the experts.

If on sheet "MAIN" in cell C3 the selection from a DDL = SKINS I'd like the code for the VinE Cup to do nothing.
or
If on the MAIN sheet cell C3 = QUOTA & SKINS or QUOTA the code would be executed.

Whichever is easiest as either way should work.

Thanks for your assistance,
VinceF
Win10
Excel 2016




Sub COPY_AND_PASTE()
Dim n As Long
Application.ScreenUpdating = False
n = Sheets("MAIN").Range("AA3").Value

With Sheets("WIN").Cells(2, 4 + n).Resize(143)
.Copy
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
Sheets("WIN").Select
Range("C5").Select
Sheets("MAIN").Select

Dim myCell As Range

Application.ScreenUpdating = False

For Each myCell In Sheets("SCORING HISTORY").Range("F5:AS141").SpecialCells(xlCellTypeFormulas, 1)
myCell.Copy
myCell.PasteSpecial xlValues
Next


With Application
.CutCopyMode = False
.ScreenUpdating = True

For Each myCell In Sheets("VinE CUP").Range("F8:AS144").SpecialCells(xlCellTypeFormulas, 1)
myCell.Copy
myCell.PasteSpecial xlValues
Next


With Application
.CutCopyMode = False
.ScreenUpdating = True

End With
Sheets("MAIN").Select
End With

End With

End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
See if this heads you in the right direction.
Note: As it stands the If statement looking for QUOTE etc is case sensitive.

VBA Code:
Sub COPY_AND_PASTE()
    Dim n As Long
    Application.ScreenUpdating = False
    n = Sheets("MAIN").Range("AA3").Value
    
    With Sheets("WIN").Cells(2, 4 + n).Resize(143)
        .Value = .Value
    End With
        
    Dim myCell As Range
    
    For Each myCell In Sheets("SCORING HISTORY").Range("F5:AS141").SpecialCells(xlCellTypeFormulas, 1)
        With myCell
            .Value = .Value
        End With
    Next myCell
    
    If Sheets("MAIN").Range("C3").Value = "QUOTA & SKINS" _
        Or Sheets("MAIN").Range("C3").Value = "QUOTA" Then
            For Each myCell In Sheets("VinE CUP").Range("F8:AS144").SpecialCells(xlCellTypeFormulas, 1)
                With myCell
                    .Value = .Value
                End With
            Next myCell
    End If
    
    Application.ScreenUpdating = True
    Sheets("MAIN").Select

End Sub
 
Upvote 0
Solution
Thank you Alex, very much appreciated......working perfectly...

VinceF
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,691
Members
449,117
Latest member
Aaagu

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
Back
Top