+ Reply to Thread
Results 1 to 3 of 3

Copying Rows to to another Sheet based on the column data?

Hybrid View

BhuvanRam Copying Rows to to another... 02-03-2012, 12:34 AM
rscsmith Re: Copying Rows to to... 02-03-2012, 01:52 AM
BhuvanRam Re: Copying Rows to to... 02-04-2012, 12:56 AM
  1. #1
    Registered User
    Join Date
    01-21-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    7

    Copying Rows to to another Sheet based on the column data?

    Hi,


    I had a requirement of copying the column data from sheet to another sheet in excel based on the condition. I am able to copy the single row but i am not able to do the same. I am new to excel VBA. so i planned for an algorithm as
    1. Iterating rows using for loop
    2. Checking the condition of the particular column value


    but i am not acheive the code as above mentioned steps, and i dont know whether it hits the prformance. I had many rows nearly above 30k. so could anyone please suggest me the answer for this

    I attached an sample excel sheet
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    12-05-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010 & 2013
    Posts
    308

    Re: Copying Rows to to another Sheet based on the column data?

    Hi BhuvanRam

    The following code should be pasted in to the Macro sheet for Sheet2. Do do this, open the VBA Editor and double click Sheet2 on the left hand side.

    It will run every time that sheet is activated.

    
    Private Sub Worksheet_Activate()
    Dim rRow As Range, CurRow As Single
    CurRow = 2
    'Clear Sheet 2 to make room for the new data
    ActiveSheet.UsedRange.ClearContents
    'Do this for each row on Sheet1
    For Each rRow In Sheets("Sheet1").UsedRange.Rows
     
     'It it's the same, or the header row, copy it
     If rRow.Cells(1, 3) = "Same" Or rRow.Row = 2 Then
       rRow.Copy Destination:=ActiveSheet.Cells(CurRow, 1)
       CurRow = CurRow + 1
       End If
    
     Next rRow
    End Sub
    Best regards, Rob.

  3. #3
    Registered User
    Join Date
    01-21-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Copying Rows to to another Sheet based on the column data?

    Hi,

    Thank you for the Answer. But the problem is its taking so much of time to copy , because i had 65 Columns and 35000 Rows nearly. Do we have any other way to do it? And is it possible to copy the rows by leaving one row blank as offset(2,1)?

    thanks
    bhuvan

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1