Help with code (included)

Puppies72

Board Regular
Joined
Mar 29, 2010
Messages
211
Hi all,

I am trying to work some code and am firstly I am encountering a problem and secondly I need some help with it.

The problem is that the first section of code on sheet "Validator" works correctly and autofilters the data then copies the filtered results into the "Combat" sheet. However the second part for sheet "Ships" is copying everything over and not just the autofiltered results - I can't figure our why for the life of me :(

As for the help I would like to know how I change the second part of the code so that the data from "Ships" is pasted directly beneath the data pasted from the "Validator" in the "Combat" sheet.

As always help greatfully appreciated - code below

Code:
Sub CombatUpdaterTest()
Application.ScreenUpdating = False
Sheets("Validator").Select
ActiveSheet.Range("$A$7:$HV$500").AutoFilter Field:=63, Criteria1:=Sheets("Combat").Range("B4").Value
Selection.AutoFilter Field:=53, Criteria1:=""
Range("BD7:CX500").Select
    Selection.Copy
    Sheets("Combat").Select
    Range("A700").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
Application.CutCopyMode = False
Application.ScreenUpdating = True
Application.ScreenUpdating = False
Sheets("Ships").Select
ActiveSheet.Range("$A$6:$FC$10000").AutoFilter Field:=8, Criteria1:=Sheets("Combat").Range("B4").Value
Range("A6:AL500").Select
    Selection.Copy
    Sheets("Combat").Select
    Range("A1200").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Try like this

Code:
Sheets("Ships").Range("$A$6:$FC$10000").AutoFilter Field:=8, Criteria1:=Sheets("Combat").Range("B4").Value
Sheets("Ships").Range("A6:AL500").SpecialCells(xlCellTypeVisible).Copy
Sheets("Combat").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

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