Hello everyone!
For my line of work I work with lots of data (currently 10,000+ cells over 7 columns and counting!). Unfortunately, I am no good with VBA.
I had the following code made for me by the helpful elmer007:
The problems:
Attached are examples of what it looks like currently, and what I want it to look like (minus headers in the other sheets). https://drive.google.com/file/d/0B3wQulJjDPsnYnVZanM5TS1nYlk/view?usp=sharing
Thank you all!
For my line of work I work with lots of data (currently 10,000+ cells over 7 columns and counting!). Unfortunately, I am no good with VBA.
I had the following code made for me by the helpful elmer007:
Code:
Public Sub CopyRows()
'Counts for number of rows on Sheet2 and Sheet3
Dim dCount, rCount As Long
wCount = Application.WorksheetFunction.CountA(Sheets("TRANSF").Range("A:A"))
aCount = Application.WorksheetFunction.CountA(Sheets("SURPLUS").Range("A:A"))
sCount = Application.WorksheetFunction.CountA(Sheets("LOST").Range("A:A"))
dCount = Application.WorksheetFunction.CountA(Sheets("NO CMDB").Range("A:A"))
'Range to be used to traverse data on Sheet1
Dim myRange As Range
Set myRange = Sheets("Sheet1").Range("A1")
'Check every row until an empty row
Do Until IsEmpty(myRange)
'If disposed, put values on Sheet2
If InStr(1, UCase(myRange.Offset(0, 4)), "TRANSF") Then
Sheets("TRANSF").Cells(wCount + 1, 1).Resize(5, 7).Value = myRange.Resize(5, 7).Value
wCount = wCount + 1
End If
'If respon party, put values on Sheet3
If InStr(1, UCase(myRange.Offset(0, 4)), "SURPLUS") Then
Sheets("SURPLUS").Cells(aCount + 1, 1).Resize(5, 7).Value = myRange.Resize(5, 7).Value
aCount = aCount + 1
End If
'If not found, put values on Sheet3
If InStr(1, UCase(myRange.Offset(0, 4)), "LOST") Then
Sheets("LOST").Cells(sCount + 1, 1).Resize(5, 7).Value = myRange.Resize(5, 7).Value
sCount = sCount + 1
End If
'If respon party, put values on Sheet3
If InStr(1, UCase(myRange.Offset(0, 4)), "NO CMDB") Then
Sheets("NO CMDB").Cells(dCount + 1, 1).Resize(5, 7).Value = myRange.Resize(5, 7).Value
dCount = dCount + 1
End If
'Move range down one row
Set myRange = myRange.Offset(1, 0)
Loop
End Sub
The problems:
- Currently, this code copies columns A-G into the specified sheet. I want only columns E-G copied over
- I want the information copied to start on the second line, as opposed to the first, to be able to put headers over the data.
- When the code ends, it copies the last 4 rows of data after the final keyword-containing row, regardless of the specific data in them.
- Is there any way to copy over the rows that have any character, number, or phrase in column E, regardless of what it is, into a new sheet labeled "Not Found"?
Attached are examples of what it looks like currently, and what I want it to look like (minus headers in the other sheets). https://drive.google.com/file/d/0B3wQulJjDPsnYnVZanM5TS1nYlk/view?usp=sharing
Thank you all!