Hello All,
I have successfully copied filtered data from one table to another with the code below.
What is missing is the formatting from the source table "Data". The VBA code will only copy and paste the values. I want both data and formatting.
Sample Output: Missing Format
NOTE: This VBA code is only for TESTING. This code copies data and the formatting from a table on the source sheet to the destination sheet successfully.
Sample Output: Format Copied
Any help would be much appreciated.
Thank you!
Using Excel 2007
I have successfully copied filtered data from one table to another with the code below.
What is missing is the formatting from the source table "Data". The VBA code will only copy and paste the values. I want both data and formatting.
- How do I retain the formatting from the source table/sheet?
- If that is not possible a good work around would be to format the new copied data starting at cell A6. How do I do that? I would like to use the built in table styles in Excel 2007 like the banned rows ect.
- How do I create a hyperlink for the cells containing the IP?
- Because the VBA code only copies the data, I have lost the hyperlinks I created in the source table.
Code:
Sub FilterData()
Sheets("Search").Select
Range("A6").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Clear
Sheets("Data").Range("Data[#All]").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:= _
Sheets("Criteria").Range("A1:D2"), CopyToRange:=Sheets("Search").Range("A6"), Unique:=True
Columns.AutoFit
Cells.WrapText = False
Range("B1").Select
Range("C4").Value = Range("A" & Rows.Count).End(xlUp).Row - 6 & " Records"
End Sub
Sample Output: Missing Format

NOTE: This VBA code is only for TESTING. This code copies data and the formatting from a table on the source sheet to the destination sheet successfully.
Code:
Sub CopyData() Sheets("Data").Range("Data[#All]").Copy _
Destination:=Sheets("Search").Range("A6")
End Sub
Sample Output: Format Copied

Any help would be much appreciated.
Thank you!
Using Excel 2007