transfer data from sheet1 to sheet2 by vba

transfer data from sheet1 to sheet2 by vba
see the highlighted cell in both the sheets, we have to transfer the data from sheet1 to sheet2
this highlighted cell is only for understanding , in real file there will be no highlighted colour
Avinash SinghAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HuaMin ChenProblem resolverCommented:

1. Use Do While loop to scan through the whole sheet 1

2. Use Range.Copy to each time copy  one row and paste it to Sheet 2.
Avinash SinghAuthor Commented:
Sir i am new to Vba i tried to make the code but error is coming so plz look into it and provide me the vba code
HuaMin ChenProblem resolverCommented:
Refer to similar example below
Sub AA_SEarch_Cont()
    Dim RowID As Integer, RowID1 As Integer, RowID2 As Integer, RowID3 As Integer, Val0 As String, Count0 As Integer, Item1 As String, Pos0 As Integer, Pos1 As Integer, Item2 As String
    RowID = 2
    RowID1 = 1
    RowID2 = 1: RowID3 = 0
    Count0 = 0
    Do While True
        Item1 = Trim(Worksheets("Cont0").Cells(RowID, 2).Value)
        If Item1 = "" Then
            Count0 = Count0 + 1
            Count0 = 0
        End If
        If Count0 = 5 Then
            Exit Sub
        End If
        If Item1 <> "" Then
        Set c1 = Worksheets("Cont1").Cells.Find(Item1)
        If c1 Is Nothing Then
            'Pos0 = InStr(Worksheets("Cont1").Cells(c1.Row, 10).Value, " ")
            'Pos1 = Len(Trim(Worksheets("Cont1").Cells(c1.Row, 10).Value))
            'Worksheets("Cont0").Cells(RowID, 11).Value = Trim(Mid(Worksheets("Cont1").Cells(c1.Row, 10).Value, Pos0 + 1, Pos1 - Pos0))
            'Worksheets("Cont0").Cells(RowID, 11).Value = Replace(Worksheets("Cont1").Cells(c1.Row, 10).Value, Item1, "")
            RowID3 = RowID3 + 1: Worksheets("Cont2").Cells(RowID3, 1).Value = Worksheets("Cont0").Cells(RowID, 1).Value
            Worksheets("Cont2").Cells(RowID3, 2).Value = Worksheets("Cont0").Cells(RowID, 2).Value
        End If
        End If
        RowID = RowID + 1
End Sub

Open in new window

to handle with 2 Worksheets, and remember to use Range.Copy to copy one row.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Roy CoxGroup Finance ManagerCommented:
I'm sure that you have already asked this question.
Avinash SinghAuthor Commented:
I have 2 problems both looks almost similar but they are different
One u have solved Roy cox sir
But the second was not solved perfect
So again i have asked the question
So plz look into it and do needful and it will be a great help if u solve this problem Roy cox sir
HuaMin ChenProblem resolverCommented:
Try to correct my given example and copy the relevant rows.
Roy CoxGroup Finance ManagerCommented:
Try this

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Avinash SinghAuthor Commented:
Thnx Roy cox sir for giving ur precious time to this post
and thnx HuaMin Chen for giving ur precious time to this post
problem solved
Roy CoxGroup Finance ManagerCommented:
Pleased to help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.