+ Reply to Thread
Results 1 to 3 of 3

search value, copy and paste to a column

Hybrid View

Rick85 search value, copy and paste... 04-13-2010, 09:53 PM
rylo Re: search value, copy and... 04-14-2010, 01:15 AM
Rick85 Re: search value, copy and... 04-14-2010, 05:40 PM
  1. #1
    Registered User
    Join Date
    04-11-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    6

    Question search value, copy and paste to a column

    Hi there!

    First of all i want to thank this great community for helping so many people like me that feel lost and dizzy in the programming world of excell VBA

    So i call for help
    I need a simple macro that searches the rows of a table (A1:C10) looking for a value that start with X letter (example: X100) when found copy and paste to column G of the same row, then go search the next row for X values again to copy and paste in column G.
    If the row has no X values it means the X value is the same of the one found in the previous row, so i want to copy the X value that is in the previous row and paste it in column G present row

    I am attaching a excell file that has an example to make it more clear what i want to do:


    Was wondering if someone can help me out to do a code to acomplish this

    Regards
    Rick
    Attached Files Attached Files
    Last edited by Rick85; 04-14-2010 at 05:45 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: search value, copy and paste to a column

    Hi

    Here goes.

    Sub aaa()
      lastrow = Cells(Rows.Count, 1).End(xlUp).Row
      For Each ce In Range("A1:C" & lastrow)
        Select Case Left(ce.Value, 1)
          Case "X"
            Cells(ce.Row, "G").Value = ce.Value
          Case "Y"
            Cells(ce.Row, "H").Value = ce.Value
          Case "Z"
            Cells(ce.Row, "I").Value = ce.Value
        End Select
      Next ce
      
      For Each ce In Range("G1:I" & lastrow)
        If IsEmpty(ce) Then
          ce.Value = ce.Offset(-1, 0).Value
        End If
      
      Next ce
    End Sub
    rylo

  3. #3
    Registered User
    Join Date
    04-11-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: search value, copy and paste to a column

    rylo your code works like a charm and its easy to understand
    thank you so much for the big help, you saved me alot of trouble

    Thanks again

    Rick

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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