Copy function thinks the cell is blank

mharper90

Board Regular
Joined
May 28, 2013
Messages
117
Office Version
  1. 365
Platform
  1. MacOS
I'm using the following code to copy and send some data to another worksheet. Columns E and F are hidden AND they contain IF formulas that return a date value. When I use the code below, it appears that they are translated into the destination worksheet as blank columns. My thought is that this has to do with the fact that they are actually formulas, not dates. Is there a way to copy the displayed value instead?


Code:
[SIZE=2][FONT=arial]Sub cpypste7()

Dim x      As String
Dim y      As String
Dim ws1  As Worksheet: Set ws1 = ThisWorkbook.Sheets("Main Data")
Dim ws2  As Worksheet: Set ws2 = ThisWorkbook.Sheets("P1 Figure 2-2")


Application.ScreenUpdating = False

x = "NO"
y = "TRUE"

If Not IsError(Application.Match(x, ws1.Range("A:A"), 0)) Then

     ws1.Range("E:F").EntireColumn.Hidden = False

     ws1.Range("A7").AutoFilter Field:=1, Criteria1:=x
     ws1.Range("A7").AutoFilter Field:=19, Criteria1:=y
        Intersect(ws1.AutoFilter.Range.Offset(1), Union(ws1.Columns("B:C"), ws1.Columns("E:F"), ws1.Columns("H"))).Copy _
          Destination:=ws2.Range("A" & Rows.Count).End(xlUp).Offset(1)
     ws1.AutoFilterMode = False

     ws1.Range("E:F").EntireColumn.Hidden = True

End If

Application.ScreenUpdating = False

End Sub[/FONT][/SIZE]
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Try
Code:
     ws1.Range("A7").AutoFilter Field:=19, Criteria1:=y
         Intersect(ws1.AutoFilter.Range.Offset(1), Union(ws1.Columns("B:C"), ws1.Columns("E:F"), ws1.Columns("H"))).Copy
         ws2.Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
     ws1.AutoFilterMode = False
 
Upvote 0

Forum statistics

Threads
1,215,034
Messages
6,122,782
Members
449,095
Latest member
m_smith_solihull

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