Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Copy data from one sheet to another

Posted on 2013-06-03
Medium Priority
352 Views
I need VBA help to do the following.

If column AP sheet 4 is null then
copy ColumnC of sheet 4 to column A sheet 3
then copy column L  of sheet 4 to column B sheet3
then copy column F of sheet 4 to column C Sheet 3

for each row until there are no other blank cells in AP or first blank row for column A Sheet4.

0
Question by:leezac
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 24

Accepted Solution

Steve earned 2000 total points
ID: 39217431
The attached should do it...

``````Sub CopyData()

Dim sh3 As Worksheet: Set sh3 = ThisWorkbook.Sheets("Sheet3")
Dim sh4 As Worksheet: Set sh4 = ThisWorkbook.Sheets("Sheet4")
Dim RowSh3 As Long, RowSh4 As Long

RowSh3 = sh3.Range("A" & Rows.Count).End(xlUp).Row + 1
RowSh4 = sh4.Range("A" & Rows.Count).End(xlUp).Row

For x = 1 To RowSh4

If Len(sh4.Cells(x, "AP")) = 0 Then

sh4.Cells(x, "C").Copy sh3.Cells(RowSh3, "A")

sh4.Cells(x, "L").Copy sh3.Cells(RowSh3, "B")

sh4.Cells(x, "F").Copy sh3.Cells(RowSh3, "C")

RowSh3 = RowSh3 + 1

End If

Next x

End Sub
``````

**note** Example workbook uses P rather than AP, but code above uses AP
If you require the code to be commented, feel free to ask.
Example-Copy.xlsm
0

Author Closing Comment

ID: 39217518
Thanks - that was perfect and easy to understand. Thank you!!!
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article describes a serious pitfall that can happen when deleting shapes using VBA.