JCKTDS123456
New Member
- Joined
- Mar 14, 2016
- Messages
- 4
Dear sir,
I have a vba code that is working nice but problem is that while importing data, font size, conditional formatting etc.....is also importing along with............so please I want value to be imported to the next worksheet.............and for your king refference.........i am sending you model file...............please correct that vba code
I have a vba code that is working nice but problem is that while importing data, font size, conditional formatting etc.....is also importing along with............so please I want value to be imported to the next worksheet.............and for your king refference.........i am sending you model file...............please correct that vba code
Code:
Option Explicit
Sub copyDatabyCondition()
'copy data if column C isn't empty
Dim wsSource As Worksheet
Dim wsTarget As Worksheet
Dim LastCell, i As Long
'intialization
Set wsSource = ThisWorkbook.Sheets("Sheet2")
Set wsTarget = ThisWorkbook.Sheets("Sheet3")
'find the last row in both tables
LastCell = wsSource.Cells(wsSource.Rows.Count, "A").End(xlUp).Row
With wsSource
'for each row in the source table
For i = 4 To LastCell
'column C isn't empty?
If .Cells(i, "A") > 0 And .Cells(i, "C") = 0 Then
wsSource.Range("A" & i & ":C" & i).Copy wsTarget.Cells(wsTarget.Rows.Count, "A").End(xlUp).Offset(1, 0)
wsSource.Range("F" & i).Copy wsTarget.Cells(wsTarget.Rows.Count, "A").End(xlUp).Offset(, 5)
wsSource.Range("N" & i).Copy wsTarget.Cells(wsTarget.Rows.Count, "A").End(xlUp).Offset(, 13)
End If
Next
End With
End Sub
Last edited by a moderator: