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.
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.
Subreddit
Post Details
- Posted
- 4 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/excel/comme...