Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Macro to copy rows to new sheet based on partial string in cell
Post Flair (click to view more posts with a particular flair)
Post Body

I am fairly new to macros, any help would be wonderful.

I have a table(see below) that I want to copy rows to different sheets for each team member responsible. In row C I have data that is AB100DCE. I want to search only position "DC" and copy to a new sheet. Each sheet will need multiple values copied, so I am unsure if its easier to just search for "dc","de","df","dg" in the code, or create a new sheet with the values I want to search and copy. Here is the code I have so far, I am not sure how to add multiple values for it search and copy. I am also unsure if it would be easier to have 1 macro for each sheet I need copied to, or 1 macro that copies to multiple sheets.

Sub CopyColumC()

Dim wsSource As Worksheet
 Dim wsDestin As Worksheet
 Dim lngDestinRow As Long
 Dim rngSource As Range
 Dim rngCel As Range


 Set wsSource = Sheets("Sheet3")     'Edit "Sheet1" to your source sheet name
 Set wsDestin = Sheets("Test")


 With wsSource
     'Following line assumes column headers in Source worksheet so starts at row2
     Set rngSource = .Range(.Cells(2, "C"), .Cells(.Rows.Count, "C").End(xlUp))
 End With


 For Each rngCel In rngSource
     If rngCel.Value = "cd" Then
         With wsDestin
             'Following line assumes column headers in Destination worksheet
             lngDestinRow = .Cells(.Rows.Count, "C").End(xlUp).Offset(1, 0).Row
             rngCel.EntireRow.Copy Destination:=wsDestin.Cells(lngDestinRow, "A")
         End With
     End If
 Next rngCel

End Sub

|LE101DAC  |leggit 101 dad| :-:|:-:| |DA101LEC|dad 101 leggit| |LE102DAC|leggit 102 dad|

edit: I am unsure why the table isn't working.

Author
Account Strength
100%
Account Age
12 years
Verified Email
Yes
Verified Flair
No
Total Karma
26,405
Link Karma
13,507
Comment Karma
12,681
Profile updated: 2 days ago
Posts updated: 7 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
4 years ago