• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

If value exist in a column then select next column using macro

lkg999

New Member
I have four sheets say sheet1,sheet2... in an excel file. I want to copy data of column A of sheet1 in column A of sheet4 and copy data of column A of sheet2 in column B of sheet4 and date of column A of sheet3 in column C of sheet4. I want a macro that I can copy the data but if there is no data in column A of sheet1 then it copies data of column A of sheet2 in column A of sheet4 and data of column A of sheet3 in column B of sheet4.


Please help.
 
Hi lkg999,


Try this code


Sub CopyOnlyFullData()


Dim sRange As Range

Dim x As Integer

Dim i As Integer


x = 1

For i = 1 To 3


Set sRange = Worksheets("Sheet" & i).Range("A:A")

If Application.WorksheetFunction.CountA(sRange) <> 0 Then

sRange.Copy Sheets("Sheet4").Columns(x)

x = x + 1

End If


Next i


End Sub
 
Back
Top